summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-01-22 19:59:16 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-02-04 18:47:05 +0100
commit9ea00c70fbbe61d4c2da98c3d9390bfbada157bd (patch)
tree552f02a5a5d6881bcb1f1a7234ad65769f0c5b72 /src/plugins/sqldrivers/odbc/qsql_odbc.cpp
parentc5a2257e0bcf799cd2588f243dfa5e575a5500e0 (diff)
SQL/ODBC: Pass correct length to SQLColAttribute()
This ensures the tst_QSqlQuery::record() test passes when checking the tablename. Pick-to: 6.5 6.4 6.2 5.15 Change-Id: I146f9f627ea366c6813af61ce48b930ca1041b15 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/plugins/sqldrivers/odbc/qsql_odbc.cpp')
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
index 6d0c8ebd9d..4b7ad455f1 100644
--- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
@@ -702,10 +702,15 @@ static QSqlField qMakeFieldInfo(const SQLHANDLE hStmt, int i, QString *errorMess
f.setAutoValue(isAutoValue(hStmt, i));
QVarLengthArray<SQLTCHAR> tableName(TABLENAMESIZE);
SQLSMALLINT tableNameLen;
- r = SQLColAttribute(hStmt, i + 1, SQL_DESC_BASE_TABLE_NAME, tableName.data(),
- TABLENAMESIZE, &tableNameLen, 0);
+ r = SQLColAttribute(hStmt,
+ i + 1,
+ SQL_DESC_BASE_TABLE_NAME,
+ tableName.data(),
+ SQLSMALLINT(tableName.size() * sizeof(SQLTCHAR)), // SQLColAttribute needs/returns size in bytes
+ &tableNameLen,
+ 0);
if (r == SQL_SUCCESS)
- f.setTableName(fromSQLTCHAR(tableName, tableNameLen));
+ f.setTableName(fromSQLTCHAR(tableName, tableNameLen / sizeof(SQLTCHAR)));
return f;
}