diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 9f1cf0a1f7f..60b281179d9 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1506,7 +1506,10 @@ bytearray_translate(PyByteArrayObject *self, PyObject *args) } /* Fix the size of the resulting string */ if (inlen > 0) - PyByteArray_Resize(result, output - output_start); + if (PyByteArray_Resize(result, output - output_start) < 0) { + Py_CLEAR(result); + goto done; + } done: if (tableobj != NULL)