File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -1938,39 +1938,46 @@ whichmodule(PyObject *global, PyObject *dotted_path)
19381938        i  =  0 ;
19391939        while  (PyDict_Next (modules , & i , & module_name , & module )) {
19401940            if  (_checkmodule (module_name , module , global , dotted_path ) ==  0 ) {
1941+                 Py_DECREF (modules );
19411942                return  Py_NewRef (module_name );
19421943            }
19431944            if  (PyErr_Occurred ()) {
1945+                 Py_DECREF (modules );
19441946                return  NULL ;
19451947            }
19461948        }
19471949    }
19481950    else  {
19491951        PyObject  * iterator  =  PyObject_GetIter (modules );
19501952        if  (iterator  ==  NULL ) {
1953+             Py_DECREF (modules );
19511954            return  NULL ;
19521955        }
19531956        while  ((module_name  =  PyIter_Next (iterator ))) {
19541957            module  =  PyObject_GetItem (modules , module_name );
19551958            if  (module  ==  NULL ) {
19561959                Py_DECREF (module_name );
19571960                Py_DECREF (iterator );
1961+                 Py_DECREF (modules );
19581962                return  NULL ;
19591963            }
19601964            if  (_checkmodule (module_name , module , global , dotted_path ) ==  0 ) {
19611965                Py_DECREF (module );
19621966                Py_DECREF (iterator );
1967+                 Py_DECREF (modules );
19631968                return  module_name ;
19641969            }
19651970            Py_DECREF (module );
19661971            Py_DECREF (module_name );
19671972            if  (PyErr_Occurred ()) {
19681973                Py_DECREF (iterator );
1974+                 Py_DECREF (modules );
19691975                return  NULL ;
19701976            }
19711977        }
19721978        Py_DECREF (iterator );
19731979    }
1980+     Py_DECREF (modules );
19741981
19751982    /* If no module is found, use __main__. */ 
19761983    return  & _Py_ID (__main__ );
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments