summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index e0e3cd0..1cfdbae 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2609,17 +2609,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);