summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/odbcbase/OTools.cxx
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-04-15 01:27:39 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2013-04-15 01:29:03 +0200
commita63c9bac6a6223ac716b7bcb590dac4eb01d5def (patch)
treed7f3ca8cd3f824831e1a650600ecd5a0348b3e1f /connectivity/source/drivers/odbcbase/OTools.cxx
parenta5aeb9e0a0e8766ddaefb147f24ca858f0fff75b (diff)
fdo#61142 mixup between size and length
Change-Id: Ia2903d5139378e97bb2e8d00ccb2c213d3e1dee6
Diffstat (limited to 'connectivity/source/drivers/odbcbase/OTools.cxx')
-rw-r--r--connectivity/source/drivers/odbcbase/OTools.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index 3e3f39311d4d..4f85184060b6 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -424,11 +424,15 @@ OUString OTools::getStringValue(OConnection* _pConnection,
// we assume everyone (LibO & ODBC) uses UTF-16; see OPreparedStatement::setParameter
BOOST_STATIC_ASSERT(sizeof(sal_Unicode) == 2);
BOOST_STATIC_ASSERT(sizeof(SQLWCHAR) == 2);
+ BOOST_STATIC_ASSERT(sizeof(waCharArray) % 2 == 0);
+ // Size == number of bytes, Len == number of UTF-16 code units
+ const SQLLEN nMaxSize = sizeof(waCharArray);
+ const SQLLEN nMaxLen = sizeof(waCharArray) / sizeof(sal_Unicode);
+ BOOST_STATIC_ASSERT(nMaxLen * sizeof(sal_Unicode) == nMaxSize);
+
// read the unicode data
- const SQLLEN nMaxLen = sizeof(waCharArray) / sizeof(sal_Unicode);
SQLLEN pcbValue = SQL_NO_TOTAL;
-
- while ((pcbValue == SQL_NO_TOTAL ) || (pcbValue >= nMaxLen) )
+ while ((pcbValue == SQL_NO_TOTAL ) || (pcbValue >= nMaxSize) )
{
OTools::ThrowException(_pConnection,
(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(
@@ -446,7 +450,7 @@ OUString OTools::getStringValue(OConnection* _pConnection,
SQLLEN nReadChars;
OSL_ENSURE( (pcbValue < 0) || (pcbValue % 2 == 0),
"ODBC: SQLGetData of SQL_C_WCHAR returned odd number of bytes");
- if ( (pcbValue == SQL_NO_TOTAL) || (pcbValue >= nMaxLen) )
+ if ( (pcbValue == SQL_NO_TOTAL) || (pcbValue >= nMaxSize) )
{
// we filled the buffer; remove the terminating null character
nReadChars = nMaxLen-1;