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

Skip to content

Commit 22a1d17

Browse files
committed
Fix another refleak
1 parent 538ba2a commit 22a1d17

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Python/import.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,11 +2881,15 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals,
28812881
Py_INCREF(final_mod);
28822882
}
28832883
else {
2884-
Py_ssize_t cut_off = PyUnicode_GetLength(name) -
2885-
PyUnicode_GetLength(front);
2886-
Py_ssize_t abs_name_len = PyUnicode_GetLength(abs_name);
2884+
Py_ssize_t cut_off = PyUnicode_GET_LENGTH(name) -
2885+
PyUnicode_GET_LENGTH(front);
2886+
Py_ssize_t abs_name_len = PyUnicode_GET_LENGTH(abs_name);
28872887
PyObject *to_return = PyUnicode_Substring(abs_name, 0,
28882888
abs_name_len - cut_off);
2889+
Py_DECREF(front);
2890+
if (to_return == NULL) {
2891+
goto error_with_unlock;
2892+
}
28892893

28902894
final_mod = PyDict_GetItem(interp->modules, to_return);
28912895
Py_DECREF(to_return);

0 commit comments

Comments
 (0)