summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorOcke Janssen <oj@openoffice.org>2011-03-10 12:54:21 +0100
committerOcke Janssen <oj@openoffice.org>2011-03-10 12:54:21 +0100
commit0840df75dec4a7c04da12cdbfa291fc5caeb19cf (patch)
tree33ae04240922e77896c079a206304dde19c950cc /connectivity
parent7bd65500828eec5062bfa74e9988771ccc0f797e (diff)
dba34d: #i116509# check if first and previous work
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/ado/AResultSet.cxx2
-rw-r--r--connectivity/source/drivers/dbase/DNoException.cxx15
-rw-r--r--connectivity/source/drivers/dbase/DTable.cxx2
-rw-r--r--connectivity/source/drivers/dbase/dindexnode.cxx13
-rw-r--r--connectivity/source/drivers/odbcbase/OResultSet.cxx19
-rw-r--r--connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx6
-rw-r--r--connectivity/source/drivers/odbcbase/OStatement.cxx12
7 files changed, 46 insertions, 23 deletions
diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx
index 0c5db12c3355..2d902eb45c4f 100644
--- a/connectivity/source/drivers/ado/AResultSet.cxx
+++ b/connectivity/source/drivers/ado/AResultSet.cxx
@@ -400,7 +400,7 @@ void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
if(first())
- previous();
+ m_bOnFirstAfterOpen = !previous();
}
// -------------------------------------------------------------------------
void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/dbase/DNoException.cxx b/connectivity/source/drivers/dbase/DNoException.cxx
index 7534d06f068c..4f2e4890d705 100644
--- a/connectivity/source/drivers/dbase/DNoException.cxx
+++ b/connectivity/source/drivers/dbase/DNoException.cxx
@@ -242,7 +242,7 @@ void ODbaseTable::AllocBuffer()
}
// Falls noch kein Puffer vorhanden: allozieren:
- if (m_pBuffer == NULL && nSize)
+ if (m_pBuffer == NULL && nSize > 0)
{
m_nBufferSize = nSize;
m_pBuffer = new sal_uInt8[m_nBufferSize+1];
@@ -504,11 +504,14 @@ SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& r
sal_uIntPtr nTell = rStream.Tell() % 512;
sal_uInt16 nBufferSize = rStream.GetBufferSize();
sal_uIntPtr nSize = nBufferSize - nTell;
- char* pEmptyData = new char[nSize];
- memset(pEmptyData,0x00,nSize);
- rStream.Write((sal_uInt8*)pEmptyData,nSize);
- rStream.Seek(nTell);
- delete [] pEmptyData;
+ if ( nSize <= nBufferSize )
+ {
+ char* pEmptyData = new char[nSize];
+ memset(pEmptyData,0x00,nSize);
+ rStream.Write((sal_uInt8*)pEmptyData,nSize);
+ rStream.Seek(nTell);
+ delete [] pEmptyData;
+ }
}
return rStream;
}
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index a0844b93b0b7..6868fa72c18e 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -2822,7 +2822,7 @@ void ODbaseTable::AllocBuffer()
}
// Falls noch kein Puffer vorhanden: allozieren:
- if (m_pBuffer == NULL && nSize)
+ if (m_pBuffer == NULL && nSize > 0)
{
m_nBufferSize = nSize;
m_pBuffer = new sal_uInt8[m_nBufferSize+1];
diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx
index 767595d06b85..5e153e2f6111 100644
--- a/connectivity/source/drivers/dbase/dindexnode.cxx
+++ b/connectivity/source/drivers/dbase/dindexnode.cxx
@@ -926,11 +926,14 @@ SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& r
sal_uIntPtr nTell = rStream.Tell() % PAGE_SIZE;
sal_uInt16 nBufferSize = rStream.GetBufferSize();
sal_uIntPtr nRemainSize = nBufferSize - nTell;
- char* pEmptyData = new char[nRemainSize];
- memset(pEmptyData,0x00,nRemainSize);
- rStream.Write((sal_uInt8*)pEmptyData,nRemainSize);
- rStream.Seek(nTell);
- delete [] pEmptyData;
+ if ( nRemainSize <= nBufferSize )
+ {
+ char* pEmptyData = new char[nRemainSize];
+ memset(pEmptyData,0x00,nRemainSize);
+ rStream.Write((sal_uInt8*)pEmptyData,nRemainSize);
+ rStream.Seek(nTell);
+ delete [] pEmptyData;
+ }
}
return rStream;
}
diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx
index 7055bd273370..24c7b4a3a892 100644
--- a/connectivity/source/drivers/odbcbase/OResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx
@@ -1365,15 +1365,24 @@ sal_Bool OResultSet::isBookmarkable() const
//------------------------------------------------------------------------------
void OResultSet::setFetchDirection(sal_Int32 _par0)
{
- N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
+ OSL_ENSURE(_par0>0,"Illegal fetch direction!");
+ if ( _par0 > 0 )
+ {
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
+ }
}
//------------------------------------------------------------------------------
void OResultSet::setFetchSize(sal_Int32 _par0)
{
- N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
- delete m_pRowStatusArray;
- m_pRowStatusArray = new SQLUSMALLINT[_par0];
- N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER);
+ OSL_ENSURE(_par0>0,"Illegal fetch size!");
+ if ( _par0 > 0 )
+ {
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
+ delete m_pRowStatusArray;
+
+ m_pRowStatusArray = new SQLUSMALLINT[_par0];
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER);
+ }
}
// -------------------------------------------------------------------------
IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
diff --git a/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx
index db4538b76e10..7a47a36545a2 100644
--- a/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx
+++ b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx
@@ -60,7 +60,11 @@ OResultSetMetaData::~OResultSetMetaData()
);
::rtl::OUString sValue;
if ( nRet == SQL_SUCCESS )
+ {
+ if ( nRealLen < 0 )
+ nRealLen = BUFFER_LEN;
sValue = ::rtl::OUString(pName,nRealLen,m_pConnection->getTextEncoding());
+ }
delete [] pName;
OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
if(nRealLen > BUFFER_LEN)
@@ -74,7 +78,7 @@ OResultSetMetaData::~OResultSetMetaData()
&nRealLen,
NULL
);
- if ( nRet == SQL_SUCCESS )
+ if ( nRet == SQL_SUCCESS && nRealLen > 0)
sValue = ::rtl::OUString(pName,nRealLen,m_pConnection->getTextEncoding());
delete [] pName;
OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
diff --git a/connectivity/source/drivers/odbcbase/OStatement.cxx b/connectivity/source/drivers/odbcbase/OStatement.cxx
index 874e24c20e75..1ffe2b0ffbca 100644
--- a/connectivity/source/drivers/odbcbase/OStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OStatement.cxx
@@ -875,12 +875,16 @@ void OStatement_Base::setFetchDirection(sal_Int32 _par0)
void OStatement_Base::setFetchSize(sal_Int32 _par0)
{
OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ OSL_ENSURE(_par0>0,"Illegal fetch size!");
+ if ( _par0 > 0 )
+ {
- SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
+ SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
- delete m_pRowStatusArray;
- m_pRowStatusArray = new SQLUSMALLINT[_par0];
- nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER);
+ delete m_pRowStatusArray;
+ m_pRowStatusArray = new SQLUSMALLINT[_par0];
+ nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER);
+ }
}
//------------------------------------------------------------------------------
void OStatement_Base::setMaxFieldSize(sal_Int32 _par0)