Skip to content

Commit 936a405

Browse files
committed
BUG#37399636: The C-extension has a memory leak when working with prepared statements
Fixed a memory leak in the C-extension occurring in prepared statements. Prepared statement object reference counting was being incremented upon instantiation, but never decremented when closing the statement. Change-Id: Icbac790d47362a695f38666cecc79ad8cae1494b
1 parent 790e6e9 commit 936a405

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ v9.3.0
1818
- BUG#37453587: Github links in PyPI project's pages do not work
1919
- BUG#37447394: Unable to escape a parameter marker (`%s`) used in a query that should not be treated as a parameter marker
2020
- BUG#37418436: Arbitrary File Read in MySQL Python Client library
21+
- BUG#37399636: The C-extension has a memory leak when working with prepared statements
2122

2223
v9.2.0
2324
======

mysql-connector-python/src/mysql_capi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3259,8 +3259,6 @@ void
32593259
MySQLPrepStmt_dealloc(MySQLPrepStmt *self)
32603260
{
32613261
if (self) {
3262-
MySQLPrepStmt_free_result(self);
3263-
MySQLPrepStmt_close(self);
32643262
Py_TYPE(self)->tp_free((PyObject *)self);
32653263
}
32663264
}
@@ -3951,6 +3949,10 @@ MySQLPrepStmt_close(MySQLPrepStmt *self)
39513949
return NULL;
39523950
}
39533951

3952+
// Decrementing the reference counting - counterpart of the
3953+
// increment taking place at MySQL_stmt_prepare.
3954+
Py_XDECREF(self);
3955+
39543956
Py_RETURN_NONE;
39553957
}
39563958

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy