Skip to content

Commit 51f21fe

Browse files
committed
Fix of the memory leaks discoverd with different analyzers.
1 parent c2b53d0 commit 51f21fe

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

driver/class/ServerSidePreparedStatement.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ namespace mariadb
3333
{
3434
ServerSidePreparedStatement::~ServerSidePreparedStatement()
3535
{
36+
if (parRowCallback) {
37+
delete parRowCallback;
38+
}
3639
if (serverPrepareResult) {
3740
if (serverPrepareResult->canBeDeallocate()) {
3841
delete serverPrepareResult;
@@ -295,6 +298,9 @@ namespace mariadb
295298
bool ServerSidePreparedStatement::setParamCallback(ParamCodec* callback, uint32_t param)
296299
{
297300
if (param == uint32_t(-1)) {
301+
if (parRowCallback) {
302+
delete parRowCallback;
303+
}
298304
parRowCallback= callback;
299305
if (callback != nullptr) {
300306
mysql_stmt_attr_set(serverPrepareResult->getStatementId(), STMT_ATTR_CB_USER_DATA, (void*)this);

driver/ma_connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct MADB_Dbc
3737
MADB_Env::ListIterator ListItem;
3838
Client_Charset Charset= {0,nullptr};
3939
Unique::Protocol guard;
40-
unsigned long long LastInsertId;
40+
unsigned long long LastInsertId= 0;
4141
MYSQL* mariadb= nullptr; /* handle to a mariadb connection */
4242
MADB_Env* Environment= nullptr; /* global environment */
4343
MADB_Dsn* Dsn= nullptr;

driver/ma_dll.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ BOOL __stdcall DllMain ( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved
3030
mysql_library_init(0, NULL, NULL);
3131
break;
3232
case DLL_PROCESS_DETACH:
33-
mysql_library_end();
3433
DriverGlobalClean();
3534
break;
3635
case DLL_THREAD_ATTACH:

driver/ma_driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ extern "C" {
5050
/* {{{ DriverGlobalClean()*/
5151
void DriverGlobalClean(void)
5252
{
53-
// There is no need to lock here at least the while it used the way it used now -
53+
// There is no need to lock here at least while it used the way it used now -
5454
// only called when library is unloaded
5555
if (deletedStmt)
5656
{
5757
MADB_ListFree(deletedStmt, FALSE);
5858
}
59+
mysql_library_end();
5960
}
6061
/* }}} */
6162
}

0 commit comments

Comments
 (0)