Mercurial > cpython-lru_cache-weakref
diff Objects/moduleobject.c @ 78178:7140d97d36fd 3.2
Issue #15394: Fix ref leaks in PyModule_Create.
Patch by Julia Lawall.
| author | Meador Inge <meadori@gmail.com> |
|---|---|
| date | Thu, 19 Jul 2012 13:45:43 -0500 |
| parents | 3c9232a684ae |
| children | 571777bf5527 |
line wrap: on
line diff
--- a/Objects/moduleobject.c Thu Jul 19 00:01:22 2012 -0500 +++ b/Objects/moduleobject.c Thu Jul 19 13:45:43 2012 -0500 @@ -117,8 +117,10 @@ d = PyModule_GetDict((PyObject*)m); if (module->m_methods != NULL) { n = PyUnicode_FromString(name); - if (n == NULL) + if (n == NULL) { + Py_DECREF(m); return NULL; + } for (ml = module->m_methods; ml->ml_name != NULL; ml++) { if ((ml->ml_flags & METH_CLASS) || (ml->ml_flags & METH_STATIC)) { @@ -126,16 +128,19 @@ "module functions cannot set" " METH_CLASS or METH_STATIC"); Py_DECREF(n); + Py_DECREF(m); return NULL; } v = PyCFunction_NewEx(ml, (PyObject*)m, n); if (v == NULL) { Py_DECREF(n); + Py_DECREF(m); return NULL; } if (PyDict_SetItemString(d, ml->ml_name, v) != 0) { Py_DECREF(v); Py_DECREF(n); + Py_DECREF(m); return NULL; } Py_DECREF(v); @@ -146,6 +151,7 @@ v = PyUnicode_FromString(module->m_doc); if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) { Py_XDECREF(v); + Py_DECREF(m); return NULL; } Py_DECREF(v);
