Fix out of bounds read in tst_qsqlquery

Change-Id: I87962a17b13d212fa7fcc30bcd40174f2a7cded0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Lars Knoll 2019-12-08 11:48:46 +01:00
parent 063e39df13
commit 8da5d35ae8

View File

@ -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