diff --git a/Objects/longobject.c b/Objects/longobject.c index 80fe724d345..7e12b348848 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1628,8 +1628,10 @@ long_to_decimal_string_internal(PyObject *aa, strlen++; } if (writer) { - if (_PyUnicodeWriter_Prepare(writer, strlen, '9') == -1) + if (_PyUnicodeWriter_Prepare(writer, strlen, '9') == -1) { + Py_DECREF(scratch); return -1; + } kind = writer->kind; str = NULL; }