Commit 5eb397e6 authored by Neal Norwitz's avatar Neal Norwitz

SF # 669553, fix memory (ref) leaks

Will backport.
parent 92ace848
...@@ -1332,24 +1332,36 @@ xmlparse_getattr(xmlparseobject *self, char *name) ...@@ -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) { if (strcmp(name, "__members__") == 0) {
int i; int i;
PyObject *rc = PyList_New(0); PyObject *rc = PyList_New(0);
for (i = 0; handler_info[i].name != NULL; i++) { 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")); APPEND(rc, "ErrorCode");
PyList_Append(rc, PyString_FromString("ErrorLineNumber")); APPEND(rc, "ErrorLineNumber");
PyList_Append(rc, PyString_FromString("ErrorColumnNumber")); APPEND(rc, "ErrorColumnNumber");
PyList_Append(rc, PyString_FromString("ErrorByteIndex")); APPEND(rc, "ErrorByteIndex");
PyList_Append(rc, PyString_FromString("buffer_size")); APPEND(rc, "buffer_size");
PyList_Append(rc, PyString_FromString("buffer_text")); APPEND(rc, "buffer_text");
PyList_Append(rc, PyString_FromString("buffer_used")); APPEND(rc, "buffer_used");
PyList_Append(rc, PyString_FromString("ordered_attributes")); APPEND(rc, "ordered_attributes");
PyList_Append(rc, PyString_FromString("returns_unicode")); APPEND(rc, "returns_unicode");
PyList_Append(rc, PyString_FromString("specified_attributes")); APPEND(rc, "specified_attributes");
PyList_Append(rc, PyString_FromString("intern")); APPEND(rc, "intern");
#undef APPEND
return rc; return rc;
} }
return Py_FindMethod(xmlparse_methods, (PyObject *)self, name); return Py_FindMethod(xmlparse_methods, (PyObject *)self, name);
......
...@@ -606,9 +606,16 @@ int_neg(PyIntObject *v) ...@@ -606,9 +606,16 @@ int_neg(PyIntObject *v)
a = v->ob_ival; a = v->ob_ival;
x = -a; x = -a;
if (a < 0 && x < 0) { if (a < 0 && x < 0) {
PyObject *o;
if (err_ovf("integer negation")) if (err_ovf("integer negation"))
return NULL; return NULL;
return PyNumber_Negative(PyLong_FromLong(a)); o = PyLong_FromLong(a);
if (o != NULL) {
PyObject *result = PyNumber_Negative(o);
Py_DECREF(o);
return result;
}
return NULL;
} }
return PyInt_FromLong(x); return PyInt_FromLong(x);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment