diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 0fd10fa00d1..ba2c2e978c6 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -434,8 +434,10 @@ formatfloat(PyObject *v, int flags, int prec, int type, len = strlen(p); if (writer != NULL) { str = _PyBytesWriter_Prepare(writer, str, len); - if (str == NULL) + if (str == NULL) { + PyMem_Free(p); return NULL; + } memcpy(str, p, len); PyMem_Free(p); str += len;