diff options
| author | Andrew M. Kuchling <amk@amk.ca> | 2006-10-03 18:32:25 +0000 |
|---|---|---|
| committer | Andrew M. Kuchling <amk@amk.ca> | 2006-10-03 18:32:25 +0000 |
| commit | 1c0d8f0fec23517563d5c50c27040b6a2730d5d9 (patch) | |
| tree | 4cd408132be0936425e613e8e9f2319d9495e96e | |
| parent | 612743192e317aadc6c0b7a91100ed2bca244c38 (diff) | |
| download | cpython-git-1c0d8f0fec23517563d5c50c27040b6a2730d5d9.tar.gz | |
[Backport r50678 | neal.norwitz]
Fix memory leak under some conditions.
Reported by Klocwork, #98.
| -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 5033819d8c..fff4b836b8 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1847,11 +1847,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 */ @@ -1859,22 +1858,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; } |
