File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ _Py_GetMainfile(char *buffer, size_t maxlen)
2525 PyThreadState * tstate = _PyThreadState_GET ();
2626 PyObject * module = _Py_GetMainModule (tstate );
2727 if (_Py_CheckMainModule (module ) < 0 ) {
28+ Py_XDECREF (module );
2829 return -1 ;
2930 }
3031 Py_ssize_t size = _PyModule_GetFilenameUTF8 (module , buffer , maxlen );
@@ -130,6 +131,7 @@ ensure_isolated_main(PyThreadState *tstate, struct sync_module *main)
130131 if (_Py_CheckMainModule (mod ) < 0 ) {
131132 // This is probably unrecoverable, so don't bother caching the error.
132133 assert (_PyErr_Occurred (tstate ));
134+ Py_XDECREF (mod );
133135 return -1 ;
134136 }
135137 PyObject * loaded = NULL ;
@@ -2876,6 +2878,7 @@ _ensure_main_ns(_PyXI_session *session, _PyXI_failure *failure)
28762878 // Cache __main__.__dict__.
28772879 PyObject * main_mod = _Py_GetMainModule (tstate );
28782880 if (_Py_CheckMainModule (main_mod ) < 0 ) {
2881+ Py_XDECREF (main_mod );
28792882 if (failure != NULL ) {
28802883 * failure = (_PyXI_failure ){
28812884 .code = _PyXI_ERR_MAIN_NS_FAILURE ,
You can’t perform that action at this time.
0 commit comments