diff options
author | Andy Shaw <andy.shaw@qt.io> | 2018-03-07 15:12:13 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2018-03-17 23:14:14 +0000 |
commit | e4e87a2ece1e0c9901514fea094f31863b64b570 (patch) | |
tree | 25990d2116e284790b4c95005dbe302e1f48f6d1 /src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | |
parent | f6f40014c417aa90d4c805719e70910f522047e4 (diff) |
sqlite: Prevent a crash when sqlite does not detect any parameters
When using a virtual table inside a SQLite database it is possible that
it does not report the right number of parameters. Therefore we need
to account for this case to prevent it from crashing when trying to
bind parameters it thinks does not exist.
Task-number: QTBUG-66816
Change-Id: I3ff70bb1fe73091f43c3df53616f75858e451cfd
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp')
-rw-r--r-- | src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index d1a6582c5a..f715d3cba3 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -467,7 +467,10 @@ bool QSQLiteResult::exec() #if (SQLITE_VERSION_NUMBER >= 3003011) // In the case of the reuse of a named placeholder - if (paramCount < values.count()) { + // We need to check explicitly that paramCount is greater than 1, as sqlite + // can end up in a case where for virtual tables it returns 0 even though it + // has parameters + if (paramCount > 1 && paramCount < values.count()) { const auto countIndexes = [](int counter, const QList<int>& indexList) { return counter + indexList.length(); }; |