diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2012-07-15 13:21:08 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2012-07-15 13:21:08 (GMT) |
commit | b7a5894c64f4ac8353a90e518433cfe025b5b5bc (patch) | |
tree | 729833638913f24c10b4e73d6eeb3060ec3f6ae3 /Python/pythonrun.c | |
parent | ceda83c6a962bb34bc51cf3fc63e3ff5ff5d9f95 (diff) | |
download | cpython-b7a5894c64f4ac8353a90e518433cfe025b5b5bc.zip cpython-b7a5894c64f4ac8353a90e518433cfe025b5b5bc.tar.gz cpython-b7a5894c64f4ac8353a90e518433cfe025b5b5bc.tar.bz2 |
Refcounting fixes
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 33ac741..6ee9a5f 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1356,6 +1356,7 @@ static set_main_loader(PyObject *d, const char *filename, const char *loader_nam PyInterpreterState *interp; PyThreadState *tstate; PyObject *loader_type, *loader; + int result = 0; /* Get current thread state and interpreter pointer */ tstate = PyThreadState_GET(); interp = tstate->interp; @@ -1364,12 +1365,15 @@ static set_main_loader(PyObject *d, const char *filename, const char *loader_nam return -1; } loader = PyObject_CallFunction(loader_type, "ss", "__main__", filename); - if (loader == NULL || - (PyDict_SetItemString(d, "__loader__", loader) < 0)) { + Py_DECREF(loader_type); + if (loader == NULL) { return -1; } + if (PyDict_SetItemString(d, "__loader__", loader) < 0) { + result = -1; + } Py_DECREF(loader); - return 0; + return result; } int |