diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-12-08 11:48:46 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-12-08 18:20:43 +0100 |
commit | 8da5d35ae8ef0342adddf11705cad8ed60f871ad (patch) | |
tree | 1595ca47197bb5ee3bc1b2be775765cbb55a47d0 /tests/auto | |
parent | 063e39df13dd53975d7d6615aa9f7e8429648aed (diff) |
Fix out of bounds read in tst_qsqlquery
Change-Id: I87962a17b13d212fa7fcc30bcd40174f2a7cded0
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 1a5aa63489..4c3749eaee 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -1846,7 +1846,8 @@ void tst_QSqlQuery::precision() QSKIP("DB unable to store high precision"); const QString qtest_precision(qTableName("qtest_precision", __FILE__, db)); - static const char* precStr = "1.2345678901234567891"; + static const char precStr[] = "1.2345678901234567891"; + const int precStrLen = sizeof(precStr); { // need a new scope for SQLITE @@ -1868,7 +1869,7 @@ void tst_QSqlQuery::precision() if ( !val.startsWith( "1.2345678901234567891" ) ) { int i = 0; - while ( precStr[i] != 0 && *( precStr + i ) == val[i].toLatin1() ) + while ( i < precStrLen && i < val.size() && precStr[i] != 0 && *( precStr + i ) == val[i].toLatin1() ) i++; // MySQL and TDS have crappy precisions by default |