summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2020-05-09 13:45:10 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2020-05-09 21:17:37 +0200
commita79194007fc0522d134ca2922ef59129fe7aa354 (patch)
tree25c1c87d53f17112664b99afd06636f5dcfdc511 /connectivity
parentb577de1becb6e606cc0c80b310fc760309184d19 (diff)
mysql-sdbc: resultset: do not keep m_pResult after freeing it
and replace m_bResultFetched by (m_pResult == nullptr) Change-Id: I81dc9f1be9a72813a8a31c214ea6f8c43a1e37d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93850 Tested-by: Jenkins Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx18
-rw-r--r--connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx1
2 files changed, 14 insertions, 5 deletions
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
index bd405dea973d..75c229823004 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
@@ -111,12 +111,13 @@ OResultSet::OResultSet(OConnection& rConn, OCommonStatement* pStmt, MYSQL_RES* p
, m_pResult(pResult)
, m_encoding(_encoding)
{
+ assert(m_pResult);
m_xMetaData = new OResultSetMetaData(rConn, m_pResult);
}
void OResultSet::ensureResultFetched()
{
- if (!m_bResultFetched)
+ if (m_pResult)
{
fetchResult();
}
@@ -124,7 +125,7 @@ void OResultSet::ensureResultFetched()
void OResultSet::ensureFieldInfoFetched()
{
- if (m_bResultFetched)
+ if (m_pResult == nullptr)
return; // already fetched
// it works only if result set is produced via mysql_store_result
@@ -165,8 +166,8 @@ void OResultSet::fetchResult()
if (errorNum)
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(
mysql_error(m_pMysql), mysql_sqlstate(m_pMysql), errorNum, *this, m_encoding);
- m_bResultFetched = true;
mysql_free_result(m_pResult);
+ m_pResult = nullptr;
}
void OResultSet::disposing()
@@ -175,6 +176,11 @@ void OResultSet::disposing()
MutexGuard aGuard(m_aMutex);
+ if (m_pResult != nullptr)
+ {
+ mysql_free_result(m_pResult);
+ m_pResult = nullptr;
+ }
m_aStatement = nullptr;
m_xMetaData = nullptr;
}
@@ -575,7 +581,11 @@ void SAL_CALL OResultSet::close()
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
- m_pResult = nullptr;
+ if (m_pResult != nullptr)
+ {
+ mysql_free_result(m_pResult);
+ m_pResult = nullptr;
+ }
dispose();
}
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx
index 027cc294c153..dca2bb4a9d88 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx
@@ -71,7 +71,6 @@ class OResultSet final : public OBase_Mutex,
MYSQL_RES* m_pResult;
rtl_TextEncoding m_encoding;
bool m_bWasNull = false; // did the last getXXX result null?
- bool m_bResultFetched = false;
sal_Int32 getDataLength(sal_Int32 column)
{