Skip to content

Commit 20175f8

Browse files
cmaloneymaurycy
andcommitted
review fix: handle NULL return from from PyBytes_FromStringAndSize
Co-authored-by: Maurycy Pawłowski-Wieroński <[email protected]>
1 parent cb2377c commit 20175f8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Objects/bytearrayobject.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ PyByteArray_FromStringAndSize(const char *bytes, Py_ssize_t size)
153153
else {
154154
alloc = size + 1;
155155
new->ob_bytes_object = PyBytes_FromStringAndSize(NULL, alloc);
156+
if (new->ob_bytes_object == NULL) {
157+
Py_DECREF(new);
158+
return NULL;
159+
}
156160
new->ob_bytes = PyBytes_AsString(new->ob_bytes_object);
157161
if (new->ob_bytes == NULL) {
158162
Py_DECREF(new);

0 commit comments

Comments
 (0)