summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2008-03-27 04:40:07 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2008-03-27 04:40:07 (GMT)
commit4ebd46a02d7ab56b1398d7e5393dd32dc26becac (patch)
tree15ac40635752d2521ad280ad8e0939b4fb085da2 /Objects
parent0bcd613e9fbe5ddb042680b49225f99d1fd07338 (diff)
downloadcpython-4ebd46a02d7ab56b1398d7e5393dd32dc26becac.zip
cpython-4ebd46a02d7ab56b1398d7e5393dd32dc26becac.tar.gz
cpython-4ebd46a02d7ab56b1398d7e5393dd32dc26becac.tar.bz2
Fix memory leaks
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytesobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 90990a7..23de37e 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2683,17 +2683,21 @@ bytes_extend(PyBytesObject *self, PyObject *arg)
if (! _getbytevalue(item, &value)) {
Py_DECREF(item);
Py_DECREF(it);
+ PyMem_Free(buf);
return NULL;
}
buf[len++] = value;
Py_DECREF(item);
if (len >= buf_size) {
+ char *new_buf;
buf_size = len + (len >> 1) + 1;
- buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char));
- if (buf == NULL) {
+ new_buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char));
+ if (new_buf == NULL) {
Py_DECREF(it);
+ PyMem_Free(buf);
return PyErr_NoMemory();
}
+ buf = new_buf;
}
}
Py_DECREF(it);