Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 294a9fc

Browse files
committed
fix refleak
1 parent f6219a5 commit 294a9fc

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Python/import.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,17 +3462,19 @@ imp_cache_from_source(PyObject *self, PyObject *args, PyObject *kws)
34623462
char buf[MAXPATHLEN+1];
34633463
PyObject *pathbytes;
34643464
char *cpathname;
3465-
PyObject *debug_override = Py_None;
3465+
PyObject *debug_override = NULL;
34663466
int debug = !Py_OptimizeFlag;
34673467

34683468
if (!PyArg_ParseTupleAndKeywords(
34693469
args, kws, "O&|O", kwlist,
34703470
PyUnicode_FSConverter, &pathbytes, &debug_override))
34713471
return NULL;
34723472

3473-
if (debug_override != Py_None)
3474-
if ((debug = PyObject_IsTrue(debug_override)) < 0)
3475-
return NULL;
3473+
if (debug_override != NULL &&
3474+
(debug = PyObject_IsTrue(debug_override)) < 0) {
3475+
Py_DECREF(pathbytes);
3476+
return NULL;
3477+
}
34763478

34773479
cpathname = make_compiled_pathname(
34783480
PyBytes_AS_STRING(pathbytes),

0 commit comments

Comments
 (0)