File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1993,39 +1993,46 @@ whichmodule(PyObject *global, PyObject *dotted_path)
19931993 i = 0 ;
19941994 while (PyDict_Next (modules , & i , & module_name , & module )) {
19951995 if (_checkmodule (module_name , module , global , dotted_path ) == 0 ) {
1996+ Py_DECREF (modules );
19961997 return Py_NewRef (module_name );
19971998 }
19981999 if (PyErr_Occurred ()) {
2000+ Py_DECREF (modules );
19992001 return NULL ;
20002002 }
20012003 }
20022004 }
20032005 else {
20042006 PyObject * iterator = PyObject_GetIter (modules );
20052007 if (iterator == NULL ) {
2008+ Py_DECREF (modules );
20062009 return NULL ;
20072010 }
20082011 while ((module_name = PyIter_Next (iterator ))) {
20092012 module = PyObject_GetItem (modules , module_name );
20102013 if (module == NULL ) {
20112014 Py_DECREF (module_name );
20122015 Py_DECREF (iterator );
2016+ Py_DECREF (modules );
20132017 return NULL ;
20142018 }
20152019 if (_checkmodule (module_name , module , global , dotted_path ) == 0 ) {
20162020 Py_DECREF (module );
20172021 Py_DECREF (iterator );
2022+ Py_DECREF (modules );
20182023 return module_name ;
20192024 }
20202025 Py_DECREF (module );
20212026 Py_DECREF (module_name );
20222027 if (PyErr_Occurred ()) {
20232028 Py_DECREF (iterator );
2029+ Py_DECREF (modules );
20242030 return NULL ;
20252031 }
20262032 }
20272033 Py_DECREF (iterator );
20282034 }
2035+ Py_DECREF (modules );
20292036
20302037 /* If no module is found, use __main__. */
20312038 module_name = & _Py_ID (__main__ );
You can’t perform that action at this time.
0 commit comments