[PATCH] use proper sizes for SQL(Get|Set)StmtAttr

Lionel Elie Mamane lionel at mamane.lu
Sun Jan 29 12:17:36 PST 2012


Fixes fdo#34432 (driver smashes our stack on 64bits arch)
---
 .../source/drivers/odbcbase/OResultSet.cxx         |   14 +++++++-------
 .../source/drivers/odbcbase/OStatement.cxx         |   14 +++++++-------
 connectivity/source/inc/odbc/OResultSet.hxx        |    2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx
index fa0e844..136f597 100644
--- a/connectivity/source/drivers/odbcbase/OResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx
@@ -123,7 +123,7 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) :
     catch(const Exception&)
     { // we don't want our result destroy here
     }
-    SQLINTEGER nCurType = 0;
+    SQLULEN nCurType = 0;
     try
     {
         N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nCurType,SQL_IS_UINTEGER,0);
@@ -1268,7 +1268,7 @@ Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const  Sequence<  Any >&
 //------------------------------------------------------------------------------
 sal_Int32 OResultSet::getResultSetConcurrency() const
 {
-    sal_uInt32 nValue = 0;
+    SQLULEN nValue = 0;
     SQLRETURN nReturn = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CONCURRENCY,&nValue,SQL_IS_UINTEGER,0);
     OSL_UNUSED( nReturn );
     if(SQL_CONCUR_READ_ONLY == nValue)
@@ -1281,7 +1281,7 @@ sal_Int32 OResultSet::getResultSetConcurrency() const
 //------------------------------------------------------------------------------
 sal_Int32 OResultSet::getResultSetType() const
 {
-    sal_uInt32 nValue = 0;
+    SQLULEN nValue = 0;
     N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SENSITIVITY,&nValue,SQL_IS_UINTEGER,0);
     if(SQL_SENSITIVE == nValue)
         nValue = ResultSetType::SCROLL_SENSITIVE;
@@ -1289,7 +1289,7 @@ sal_Int32 OResultSet::getResultSetType() const
         nValue = ResultSetType::SCROLL_INSENSITIVE;
     else
     {
-        SQLINTEGER nCurType = 0;
+        SQLULEN nCurType = 0;
         N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nCurType,SQL_IS_UINTEGER,0);
         if(SQL_CURSOR_KEYSET_DRIVEN == nCurType)
             nValue = ResultSetType::SCROLL_SENSITIVE;
@@ -1311,7 +1311,7 @@ sal_Int32 OResultSet::getFetchDirection() const
 //------------------------------------------------------------------------------
 sal_Int32 OResultSet::getFetchSize() const
 {
-    sal_uInt32 nValue = 0;
+    SQLULEN nValue = 0;
     N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,&nValue,SQL_IS_UINTEGER,0);
     return nValue;
 }
@@ -1329,7 +1329,7 @@ sal_Bool  OResultSet::isBookmarkable() const
     if(!m_aConnectionHandle)
         return sal_False;
 
-    sal_uInt32 nValue = 0;
+    SQLULEN nValue = 0;
     N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nValue,SQL_IS_UINTEGER,0);
 
     sal_Int32 nAttr = 0;
@@ -1680,7 +1680,7 @@ sal_Bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32
 // -----------------------------------------------------------------------------
 sal_Int32 OResultSet::getDriverPos() const
 {
-    sal_Int32 nValue = 0;
+    SQLULEN nValue = 0;
     SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_NUMBER,&nValue,SQL_IS_UINTEGER,0);
     OSL_UNUSED( nRet );
     OSL_TRACE( __FILE__": OResultSet::getDriverPos() = Ret = %d, RowNum = %d, RowPos = %d",nRet,nValue , m_nRowPos);
diff --git a/connectivity/source/drivers/odbcbase/OStatement.cxx b/connectivity/source/drivers/odbcbase/OStatement.cxx
index 1e8558c..d79e188 100644
--- a/connectivity/source/drivers/odbcbase/OStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OStatement.cxx
@@ -300,7 +300,7 @@ sal_Bool OStatement_Base::lockIfNecessary (const ::rtl::OUString& sql) throw( SQ
         OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
         try
         {
-            SQLINTEGER nLock = SQL_CONCUR_LOCK;
+            const SQLULEN nLock = SQL_CONCUR_LOCK;
             THROW_SQL(N3SQLSetStmtAttr(m_aStatementHandle, SQL_CONCURRENCY,(SQLPOINTER)(sal_IntPtr)nLock,SQL_IS_UINTEGER));
         }
         catch (const SQLWarning& warn)
@@ -683,7 +683,7 @@ sal_Int64 OStatement_Base::getMaxRows() const
 sal_Int32 OStatement_Base::getResultSetConcurrency() const
 {
     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
-    sal_uInt32 nValue;
+    SQLULEN nValue;
     SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CONCURRENCY,&nValue,SQL_IS_UINTEGER,0);
     OSL_UNUSED( nRetCode );
     if(nValue == SQL_CONCUR_READ_ONLY)
@@ -696,7 +696,7 @@ sal_Int32 OStatement_Base::getResultSetConcurrency() const
 sal_Int32 OStatement_Base::getResultSetType() const
 {
     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
-    sal_uInt32 nValue = SQL_CURSOR_FORWARD_ONLY;
+    SQLULEN nValue = SQL_CURSOR_FORWARD_ONLY;
     SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SENSITIVITY,&nValue,SQL_IS_UINTEGER,0);
     nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nValue,SQL_IS_UINTEGER,0);
     OSL_UNUSED( nRetCode );
@@ -720,7 +720,7 @@ sal_Int32 OStatement_Base::getResultSetType() const
 sal_Int32 OStatement_Base::getFetchDirection() const
 {
     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
-    sal_uInt32 nValue = 0;
+    SQLULEN nValue = 0;
     SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SCROLLABLE,&nValue,SQL_IS_UINTEGER,0);
     OSL_UNUSED( nRetCode );
 
@@ -740,7 +740,7 @@ sal_Int32 OStatement_Base::getFetchDirection() const
 sal_Int32 OStatement_Base::getFetchSize() const
 {
     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
-    sal_uInt32 nValue;
+    SQLULEN nValue;
     SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,&nValue,SQL_IS_UINTEGER,0);
     OSL_UNUSED( nRetCode );
     return nValue;
@@ -904,7 +904,7 @@ void OStatement_Base::setCursorName(const ::rtl::OUString &_par0)
 sal_Bool OStatement_Base::isUsingBookmarks() const
 {
     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
-    sal_uInt32 nValue = SQL_UB_OFF;
+    SQLULEN nValue = SQL_UB_OFF;
     SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&nValue,SQL_IS_UINTEGER,NULL);
     OSL_UNUSED( nRetCode );
     return nValue != SQL_UB_OFF;
@@ -913,7 +913,7 @@ sal_Bool OStatement_Base::isUsingBookmarks() const
 sal_Bool OStatement_Base::getEscapeProcessing() const
 {
     OSL_ENSURE( m_aStatementHandle, "StatementHandle is null!" );
-    sal_uInt32 nValue = SQL_NOSCAN_OFF;
+    SQLULEN nValue = SQL_NOSCAN_OFF;
     SQLRETURN nRetCode = N3SQLGetStmtAttr( m_aStatementHandle, SQL_ATTR_NOSCAN, &nValue, SQL_IS_UINTEGER, NULL );
     (void)nRetCode;
     return nValue == SQL_NOSCAN_OFF;
diff --git a/connectivity/source/inc/odbc/OResultSet.hxx b/connectivity/source/inc/odbc/OResultSet.hxx
index bbb3920..e843e51 100644
--- a/connectivity/source/inc/odbc/OResultSet.hxx
+++ b/connectivity/source/inc/odbc/OResultSet.hxx
@@ -142,7 +142,7 @@ namespace connectivity
             rtl_TextEncoding                            m_nTextEncoding;
             sal_Int32                                   m_nRowPos;
             sal_Int32                                   m_nLastColumnPos;       // used for m_aRow just to know where we are
-            mutable sal_uInt32                          m_nUseBookmarks;
+            mutable SQLULEN                             m_nUseBookmarks;
             SQLRETURN                                   m_nCurrentFetchState;
             sal_Bool                                    m_bWasNull;
             sal_Bool                                    m_bEOF;                 // after last record
-- 
1.7.7.3


--qDbXVdCdHGoSgWSk--


More information about the LibreOffice mailing list