summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-01-19 15:40:09 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-01-19 15:40:09 (GMT)
commitfa56e2dc409173b0abf497244977fcaeb1a39b1a (patch)
tree16f631d41a4e32099564e0833b20bfdea902a3fb /Modules
parentf4ca5a2f450edbe2d2f6723d474976077620149f (diff)
downloadcpython-fa56e2dc409173b0abf497244977fcaeb1a39b1a.zip
cpython-fa56e2dc409173b0abf497244977fcaeb1a39b1a.tar.gz
cpython-fa56e2dc409173b0abf497244977fcaeb1a39b1a.tar.bz2
SF # 669553, fix memory (ref) leaks
Will backport.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/pyexpat.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index f74751b..7e54f0e 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1332,24 +1332,36 @@ xmlparse_getattr(xmlparseobject *self, char *name)
}
}
+#define APPEND(list, str) \
+ do { \
+ PyObject *o = PyString_FromString(str); \
+ if (o != NULL) \
+ PyList_Append(list, o); \
+ Py_XDECREF(o); \
+ } while (0)
+
if (strcmp(name, "__members__") == 0) {
int i;
PyObject *rc = PyList_New(0);
for (i = 0; handler_info[i].name != NULL; i++) {
- PyList_Append(rc, get_handler_name(&handler_info[i]));
+ PyObject *o = get_handler_name(&handler_info[i]);
+ if (o != NULL)
+ PyList_Append(rc, o);
+ Py_XDECREF(o);
}
- PyList_Append(rc, PyString_FromString("ErrorCode"));
- PyList_Append(rc, PyString_FromString("ErrorLineNumber"));
- PyList_Append(rc, PyString_FromString("ErrorColumnNumber"));
- PyList_Append(rc, PyString_FromString("ErrorByteIndex"));
- PyList_Append(rc, PyString_FromString("buffer_size"));
- PyList_Append(rc, PyString_FromString("buffer_text"));
- PyList_Append(rc, PyString_FromString("buffer_used"));
- PyList_Append(rc, PyString_FromString("ordered_attributes"));
- PyList_Append(rc, PyString_FromString("returns_unicode"));
- PyList_Append(rc, PyString_FromString("specified_attributes"));
- PyList_Append(rc, PyString_FromString("intern"));
-
+ APPEND(rc, "ErrorCode");
+ APPEND(rc, "ErrorLineNumber");
+ APPEND(rc, "ErrorColumnNumber");
+ APPEND(rc, "ErrorByteIndex");
+ APPEND(rc, "buffer_size");
+ APPEND(rc, "buffer_text");
+ APPEND(rc, "buffer_used");
+ APPEND(rc, "ordered_attributes");
+ APPEND(rc, "returns_unicode");
+ APPEND(rc, "specified_attributes");
+ APPEND(rc, "intern");
+
+#undef APPEND
return rc;
}
return Py_FindMethod(xmlparse_methods, (PyObject *)self, name);