[Python-checkins] python/dist/src/Modules pyexpat.c,2.81,2.82
fdrake@users.sourceforge.net
fdrake@users.sourceforge.net
Mon, 21 Jul 2003 10:05:58 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv21537
Modified Files:
pyexpat.c
Log Message:
Fix memory leak reported & discussed on the Python XML-SIG mailing list.
This patch was provided by Jeremy Kloth, and corresponds to pyexpat.c
1.77 in the PyXML CVS.
Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.81
retrieving revision 2.82
diff -C2 -d -r2.81 -r2.82
*** pyexpat.c 27 Jun 2003 16:13:17 -0000 2.81
--- pyexpat.c 21 Jul 2003 17:05:56 -0000 2.82
***************
*** 926,931 ****
goto finally;
! if ((arg = PyTuple_New(1)) == NULL)
goto finally;
PyTuple_SET_ITEM(arg, 0, bytes);
--- 926,933 ----
goto finally;
! if ((arg = PyTuple_New(1)) == NULL) {
! Py_DECREF(bytes);
goto finally;
+ }
PyTuple_SET_ITEM(arg, 0, bytes);
***************
*** 947,951 ****
"%i bytes requested, %i returned",
buf_size, len);
- Py_DECREF(str);
goto finally;
}
--- 949,952 ----
***************
*** 988,993 ****
int bytes_read;
void *buf = XML_GetBuffer(self->itself, BUF_SIZE);
! if (buf == NULL)
return PyErr_NoMemory();
if (fp) {
--- 989,996 ----
int bytes_read;
void *buf = XML_GetBuffer(self->itself, BUF_SIZE);
! if (buf == NULL) {
! Py_DECREF(readmethod);
return PyErr_NoMemory();
+ }
if (fp) {
***************
*** 1000,1013 ****
else {
bytes_read = readinst(buf, BUF_SIZE, readmethod);
! if (bytes_read < 0)
return NULL;
}
rv = XML_ParseBuffer(self->itself, bytes_read, bytes_read == 0);
! if (PyErr_Occurred())
return NULL;
if (!rv || bytes_read == 0)
break;
}
return get_parse_result(self, rv);
}
--- 1003,1021 ----
else {
bytes_read = readinst(buf, BUF_SIZE, readmethod);
! if (bytes_read < 0) {
! Py_DECREF(readmethod);
return NULL;
+ }
}
rv = XML_ParseBuffer(self->itself, bytes_read, bytes_read == 0);
! if (PyErr_Occurred()) {
! Py_XDECREF(readmethod);
return NULL;
+ }
if (!rv || bytes_read == 0)
break;
}
+ Py_XDECREF(readmethod);
return get_parse_result(self, rv);
}