qsql_sqlite: fix segfault in dtor of orphan result

d79ae90466 accidentally removed the check
on the driver pointer before dereferencing it. This causes a segfault
when deleting a result object after its driver has already been deleted.
This situation can arise when a database is removed, explicitly or
probably also upon unloading the driver plugin, while related
results still exist. The problem affected
qttools/tests/auto/qhelpcontentmode.

Task-number: QTBUG-49836
Change-Id: I8ce8f8a5e27d787309ac2ff644b388e333d76435
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
bb10
Mark Brand 2015-12-09 01:08:20 +01:00 committed by Simon Hausmann
parent 371c2e4786
commit 02a730331e
1 changed files with 2 additions and 1 deletions

View File

@ -351,7 +351,8 @@ QSQLiteResult::QSQLiteResult(const QSQLiteDriver* db)
QSQLiteResult::~QSQLiteResult()
{
Q_D(QSQLiteResult);
const_cast<QSQLiteDriverPrivate*>(d->drv_d_func())->results.removeOne(this);
if (d->drv_d_func())
const_cast<QSQLiteDriverPrivate*>(d->drv_d_func())->results.removeOne(this);
d->cleanup();
}