Skip to content

Commit fb67d23

Browse files
committed
Write trailing null bytes on MemoryError
1 parent 53c3b51 commit fb67d23

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

Objects/bytearrayobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ bytearray_realign_data_lock_held(PyByteArrayObject *self, Py_ssize_t new_size, P
237237
}
238238

239239
if (_PyBytes_ResizeKeepOnError(&self->ob_bytes_object, alloc) < 0) {
240+
self->ob_start[size] = '\0'; /* Trailing null */
240241
return -1;
241242
}
242243
}

0 commit comments

Comments
 (0)