summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2013-04-23 20:46:43 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-24 21:57:44 (GMT)
commit64e25b0dd9ae2f289f14583827070594517adebb (patch)
tree94d8afb61c10becf6d7f451faa140cb075df7601 /src
parent37d19b88f84990cc40b11bb297dadbdb6b2c8e7a (diff)
downloadQt-64e25b0dd9ae2f289f14583827070594517adebb.zip
Qt-64e25b0dd9ae2f289f14583827070594517adebb.tar.gz
Qt-64e25b0dd9ae2f289f14583827070594517adebb.tar.bz2
qsql_odbc: fix SQLGetStmtAtt usage
Failure to initialize the variable can cause spurious non-zero values. http://msdn.microsoft.com/en-us/library/windows/desktop/ms715438(v=vs.85).aspx "..value can either be a SQLULEN value or a null-terminated character string. If the value is a SQLULEN value, some drivers may only write the lower 32-bit or 16-bit of a buffer and leave the higher-order bit unchanged. Therefore, applications should use a buffer of SQLULEN and initialize the value to 0 before calling this function. Also, the BufferLength and StringLengthPtr arguments are not used." Follow-up to 1509316a37fb2d365230d020d1dfc251c830fd56 Change-Id: I2e92eb845a2590bea0849c52bde8902adff1b419 Reviewed-by: Andy Shaw <andy.shaw@digia.com> (cherry-picked from qtbase commit af35ee291a1bbbc8627f9a17f7e104898d49b138)
Diffstat (limited to 'src')
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 24357d2..a15a894 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -967,8 +967,7 @@ bool QODBCResult::reset (const QString& query)
}
SQLULEN isScrollable = 0;
- SQLINTEGER bufferLength;
- r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
+ r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, 0);
if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
@@ -1114,7 +1113,7 @@ bool QODBCResult::fetchLast()
"Unable to fetch last"), QSqlError::ConnectionError, d));
return false;
}
- SQLINTEGER currRow;
+ SQLULEN currRow = 0;
r = SQLGetStmtAttr(d->hStmt,
SQL_ROW_NUMBER,
&currRow,
@@ -1601,8 +1600,7 @@ bool QODBCResult::exec()
}
SQLULEN isScrollable = 0;
- SQLINTEGER bufferLength;
- r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
+ r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, 0);
if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE);