# HG changeset patch # Parent bc1a178b3bc8b63feebb3f7021813247e4c7f513 diff -r bc1a178b3bc8 Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c Sat Apr 18 05:54:02 2015 +0200 +++ b/Objects/bytearrayobject.c Sat Apr 18 05:43:38 2015 +0000 @@ -330,7 +330,7 @@ PyBuffer_Release(&vo); return PyErr_NoMemory(); } - if (size < self->ob_alloc) { + if (self->ob_start + size < self->ob_bytes + self->ob_alloc) { Py_SIZE(self) = size; PyByteArray_AS_STRING(self)[Py_SIZE(self)] = '\0'; /* Trailing null byte */ }