Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3385

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/85/3385/1

fdo#61142 mixup between size and length

Change-Id: Ia2903d5139378e97bb2e8d00ccb2c213d3e1dee6
---
M connectivity/source/drivers/odbcbase/OTools.cxx
1 file changed, 9 insertions(+), 5 deletions(-)



diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx 
b/connectivity/source/drivers/odbcbase/OTools.cxx
index d568b7f..7165c4d 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -424,11 +424,15 @@
         // we assume everyone (LibO & ODBC) uses UTF-16; see OPreparedStatement::setParameter
         BOOST_STATIC_ASSERT(sizeof(sal_Unicode) == 2);
         BOOST_STATIC_ASSERT(sizeof(SQLWCHAR)    == 2);
-        // read the unicode data
-        const SQLLEN nMaxLen = sizeof(waCharArray) / sizeof(sal_Unicode);
-        SQLLEN pcbValue = SQL_NO_TOTAL;
+        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);
 
-        while ((pcbValue == SQL_NO_TOTAL ) || (pcbValue >= nMaxLen) )
+        // read the unicode data
+        SQLLEN pcbValue = SQL_NO_TOTAL;
+        while ((pcbValue == SQL_NO_TOTAL ) || (pcbValue >= nMaxSize) )
         {
             OTools::ThrowException(_pConnection,
                                    (*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(
@@ -446,7 +450,7 @@
             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;

-- 
To view, visit https://gerrit.libreoffice.org/3385
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2903d5139378e97bb2e8d00ccb2c213d3e1dee6
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Lionel Elie Mamane <lionel@mamane.lu>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.