updated for version 7.3.1162
Problem: Python: Memory leaks
Solution: Add more Py_DECREF(). (ZyX)
diff --git a/src/if_py_both.h b/src/if_py_both.h
index be75cc8..287191a 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -5354,6 +5354,7 @@
{
int i;
PyObject *other_module;
+ PyObject *attr;
for (i = 0; i < (int)(sizeof(numeric_constants)
/ sizeof(struct numeric_constant));
@@ -5392,14 +5393,26 @@
if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir")))
return -1;
ADD_OBJECT(m, "_chdir", py_chdir);
- if (PyObject_SetAttrString(other_module, "chdir", get_attr(m, "chdir")))
+ if (!(attr = get_attr(m, "chdir")))
return -1;
+ if (PyObject_SetAttrString(other_module, "chdir", attr))
+ {
+ Py_DECREF(attr);
+ return -1;
+ }
+ Py_DECREF(attr);
if ((py_fchdir = PyObject_GetAttrString(other_module, "fchdir")))
{
ADD_OBJECT(m, "_fchdir", py_fchdir);
- if (PyObject_SetAttrString(other_module,"fchdir",get_attr(m,"fchdir")))
+ if (!(attr = get_attr(m, "fchdir")))
return -1;
+ if (PyObject_SetAttrString(other_module, "fchdir", attr))
+ {
+ Py_DECREF(attr);
+ return -1;
+ }
+ Py_DECREF(attr);
}
else
PyErr_Clear();