Fix memory leaks in 64-bits ODBC driver
authorHonglei Zhang <honglei.zhang@nokia.com>
Thu, 26 Apr 2012 10:17:40 +0000 (13:17 +0300)
committerQt by Nokia <qt-info@nokia.com>
Thu, 26 Apr 2012 15:52:12 +0000 (17:52 +0200)
On 64-bits Windows system, integers and longs are still 4 bytes values.
Several functions that were previously defined with SQLINTEGER and
SQLUINTEGER parameters have been changed where appropiate to use new
SQLLEN and SQLULEN typedefs. SQLGetStmtAttr() is one of these functions.
This fix replaces SQLINTEGER with SQLULEN in appropriate functions to avoid
memory leaks.

Task-number: QTBUG-25256
Change-Id: I744927f42b8578ece60815df360e3b337ebf452a
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
src/sql/drivers/odbc/qsql_odbc.cpp

index f503f64..04bc0cc 100644 (file)
@@ -962,7 +962,8 @@ bool QODBCResult::reset (const QString& query)
         return true;
     }
 
-    SQLINTEGER isScrollable, bufferLength;
+    SQLINTEGER bufferLength;
+    SQLULEN isScrollable;
     r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
     if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
         QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
@@ -1584,7 +1585,8 @@ bool QODBCResult::exec()
         return false;
     }
 
-    SQLINTEGER isScrollable, bufferLength;
+    SQLINTEGER bufferLength;
+    SQLULEN isScrollable;
     r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
     if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
         QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE);