From 7e3a1cedf783b908e0442f2a2e4091b2fc1974ff Mon Sep 17 00:00:00 2001 From: APTX Date: Mon, 15 Apr 2013 21:25:03 +0200 Subject: [PATCH] Fix possible crash in Database::exec(). Disconnecting clears all prepared statements so a query passed to exec might would invalid. --- localmylist/database.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/localmylist/database.cpp b/localmylist/database.cpp index aba3988..b448a25 100644 --- a/localmylist/database.cpp +++ b/localmylist/database.cpp @@ -1701,13 +1701,12 @@ bool Database::exec(QSqlQuery &query) { Q_ASSERT_X(d->thread == QThread::currentThread(), "threads", "DB used from different thread"); - if (!d->db.isOpen()) + if (!isConnected()) { disconnect(); - if (!connect()) - return false; + connect(); - return retryExec(query, true); + return false; } if (!query.exec()) @@ -1719,7 +1718,7 @@ bool Database::exec(const QString &sql) { Q_ASSERT_X(d->thread == QThread::currentThread(), "threads", "DB used from different thread"); - if (!d->db.isOpen()) + if (!isConnected()) { disconnect(); if (!connect()) -- 2.52.0