Initialize the count variable used in SQLNumResultCols to 0

If the call to SQLNumResultCols fails for whatever reason then it will
not be correctly caught since the count might be higher than 0 since it is
uninitalized. This ensures that if it fails then it does not try to act as
if it succeeded.

Task-number: QTBUG-39137
Change-Id: Ifae8c1f7fac8416643f2317747f87295642a7935
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This commit is contained in:
Andy Shaw 2014-05-26 13:20:40 +02:00 committed by The Qt Project
parent d0c38291eb
commit d153e4628e
2 changed files with 6 additions and 6 deletions

View File

@ -555,7 +555,7 @@ bool QDB2Result::reset (const QString& query)
"Unable to execute statement"), QSqlError::StatementError, d));
return false;
}
SQLSMALLINT count;
SQLSMALLINT count = 0;
r = SQLNumResultCols(d->hStmt, &count);
if (count) {
setSelect(true);
@ -795,7 +795,7 @@ bool QDB2Result::exec()
"Unable to execute statement"), QSqlError::StatementError, d));
return false;
}
SQLSMALLINT count;
SQLSMALLINT count = 0;
r = SQLNumResultCols(d->hStmt, &count);
if (count) {
setSelect(true);
@ -1105,7 +1105,7 @@ bool QDB2Result::nextResult()
return false;
}
SQLSMALLINT fieldCount;
SQLSMALLINT fieldCount = 0;
r = SQLNumResultCols(d->hStmt, &fieldCount);
setSelect(fieldCount > 0);
for (int i = 0; i < fieldCount; ++i)

View File

@ -963,7 +963,7 @@ bool QODBCResult::reset (const QString& query)
if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
SQLSMALLINT count;
SQLSMALLINT count = 0;
SQLNumResultCols(d->hStmt, &count);
if (count) {
setSelect(true);
@ -1591,7 +1591,7 @@ bool QODBCResult::exec()
if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
SQLSMALLINT count;
SQLSMALLINT count = 0;
SQLNumResultCols(d->hStmt, &count);
if (count) {
setSelect(true);
@ -1723,7 +1723,7 @@ bool QODBCResult::nextResult()
}
}
SQLSMALLINT count;
SQLSMALLINT count = 0;
SQLNumResultCols(d->hStmt, &count);
if (count) {
setSelect(true);