Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4158125

Browse filesBrowse files
benjaminpmethane
authored andcommitted
Fix a reference leak in store_result and use_result if result object initialization fails. (PyMySQL#298)
1 parent c2e5ff7 commit 4158125
Copy full SHA for 4158125

File tree

Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed

‎MySQLdb/_mysql.c

Copy file name to clipboardExpand all lines: MySQLdb/_mysql.c
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,8 +1865,10 @@ _mysql_ConnectionObject_store_result(
18651865
if (!kwarglist) goto error;
18661866
r = MyAlloc(_mysql_ResultObject, _mysql_ResultObject_Type);
18671867
if (!r) goto error;
1868-
if (_mysql_ResultObject_Initialize(r, arglist, kwarglist))
1868+
if (_mysql_ResultObject_Initialize(r, arglist, kwarglist)) {
1869+
Py_DECREF(r);
18691870
goto error;
1871+
}
18701872
result = (PyObject *) r;
18711873
if (!(r->result)) {
18721874
Py_DECREF(result);
@@ -1924,9 +1926,11 @@ _mysql_ConnectionObject_use_result(
19241926
if (!kwarglist) goto error;
19251927
r = MyAlloc(_mysql_ResultObject, _mysql_ResultObject_Type);
19261928
if (!r) goto error;
1927-
result = (PyObject *) r;
1928-
if (_mysql_ResultObject_Initialize(r, arglist, kwarglist))
1929+
if (_mysql_ResultObject_Initialize(r, arglist, kwarglist)) {
1930+
Py_DECREF(r);
19291931
goto error;
1932+
}
1933+
result = (PyObject *) r;
19301934
if (!(r->result)) {
19311935
Py_DECREF(result);
19321936
Py_INCREF(Py_None);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.