Fix potential double-free in QSqlCachedResult::cleanup()

If d->sql is non-null, it gets freed; later in the same function, it
gets reallocated, unless the query is empty, in which case the
now-freed value was still recorded, so that later clean-up might find
it and mistakenly think it needs to be freed again. Clear when freeing.

Pick-to: 6.2 6.1
Change-Id: I8d37d2ba1fcaa320916eaf30dceaa720bbf62f38
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
bb10
Edward Welbourne 2021-06-21 12:13:05 +02:00
parent c42ebd5ba6
commit 0e1da78ad3
1 changed files with 3 additions and 1 deletions

View File

@ -1983,7 +1983,9 @@ bool QOCIResult::prepare(const QString& query)
if (d->sql) {
r = OCIHandleFree(d->sql, OCI_HTYPE_STMT);
if (r != OCI_SUCCESS)
if (r == OCI_SUCCESS)
d->sql = nullptr;
else
qOraWarning("QOCIResult::prepare: unable to free statement handle:", d->err);
}
if (query.isEmpty())