summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r--Objects/bytearrayobject.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 428ee57..fc12452 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -411,18 +411,18 @@ bytes_subscript(PyByteArrayObject *self, PyObject *index)
}
else {
char *source_buf = PyByteArray_AS_STRING(self);
- char *result_buf = (char *)PyMem_Malloc(slicelength);
+ char *result_buf;
PyObject *result;
- if (result_buf == NULL)
- return PyErr_NoMemory();
+ result = PyByteArray_FromStringAndSize(NULL, slicelength);
+ if (result == NULL)
+ return NULL;
+ result_buf = PyByteArray_AS_STRING(result);
for (cur = start, i = 0; i < slicelength;
cur += step, i++) {
result_buf[i] = source_buf[cur];
}
- result = PyByteArray_FromStringAndSize(result_buf, slicelength);
- PyMem_Free(result_buf);
return result;
}
}