8000 Fix ref leaks. · python/cpython@e12d3a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit e12d3a2

Browse files
Fix ref leaks.
1 parent 8dc6609 commit e12d3a2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Modules/_xxsubinterpretersmodule.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ _run_script(PyInterpreterState *interp,
531531
PyObject *code = PyMarshal_ReadObjectFromString(codestr, codestrlen);
532532
if (code != NULL) {
533533
result = PyEval_EvalCode(code, ns, ns);
534+
Py_DECREF(code);
534535
}
535536
}
536537
else {
@@ -977,7 +978,9 @@ interp_run_string(PyObject *self, PyObject *args, PyObject *kwds)
977978
return NULL;
978979
}
979980

980-
if (_interp_exec(self, id, (PyObject *)script, shared) < 0) {
981+
int res = _interp_exec(self, id, (PyObject *)script, shared);
982+
Py_DECREF(script);
983+
if (res < 0) {
981984
return NULL;
982985
}
983986
Py_RETURN_NONE;
@@ -1009,7 +1012,9 @@ interp_run_func(PyObject *self, PyObject *args, PyObject *kwds)
10091012
return NULL;
10101013
}
10111014

1012-
if (_interp_exec(self, id, (PyObject *)code, shared) < 0) {
1015+
int res = _interp_exec(self, id, (PyObject *)code, shared);
1016+
Py_DECREF(code);
1017+
if (res < 0) {
10131018
return NULL;
10141019
}
10151020
Py_RETURN_NONE;

0 commit comments

Comments
 (0)
0