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.

Change-Id: I8d37d2ba1fcaa320916eaf30dceaa720bbf62f38
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
(cherry picked from commit 0e1da78ad36a0639275b7a0ac8a046f46577452d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Edward Welbourne 2021-06-21 12:13:05 +02:00 committed by Qt Cherry-pick Bot
parent 68ba065602
commit 3e5ccbaace

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())