diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-07-16 02:17:36 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-07-16 02:17:36 (GMT) |
commit | c0cde4da2a3d7992b7405ed5e11bc43f7d2391a0 (patch) | |
tree | 79693815bea1a6e3dcd4df6e8a01e6be9ee8c30b /Python | |
parent | 5eaf772980a5013c89a9d3814991ff3244ed58f1 (diff) | |
download | cpython-c0cde4da2a3d7992b7405ed5e11bc43f7d2391a0.zip cpython-c0cde4da2a3d7992b7405ed5e11bc43f7d2391a0.tar.gz cpython-c0cde4da2a3d7992b7405ed5e11bc43f7d2391a0.tar.bz2 |
Fix memory leak under some conditions.
Reported by Klocwork, #98.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Python/import.c b/Python/import.c index 341f652..2c0468b 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1906,11 +1906,10 @@ PyImport_ImportFrozenModule(char *name) if (co == NULL) return -1; if (!PyCode_Check(co)) { - Py_DECREF(co); PyErr_Format(PyExc_TypeError, "frozen object %.200s is not a code object", name); - return -1; + goto err_return; } if (ispackage) { /* Set __path__ to the package name */ @@ -1918,22 +1917,25 @@ PyImport_ImportFrozenModule(char *name) int err; m = PyImport_AddModule(name); if (m == NULL) - return -1; + goto err_return; d = PyModule_GetDict(m); s = PyString_InternFromString(name); if (s == NULL) - return -1; + goto err_return; err = PyDict_SetItemString(d, "__path__", s); Py_DECREF(s); if (err != 0) - return err; + goto err_return; } m = PyImport_ExecCodeModuleEx(name, co, "<frozen>"); - Py_DECREF(co); if (m == NULL) - return -1; + goto err_return; + Py_DECREF(co); Py_DECREF(m); return 1; +err_return: + Py_DECREF(co); + return -1; } |