From 110ac16b9f1be086ba98aa6f1ef8d7105493d92e Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 10 Sep 2012 02:51:27 +0200 Subject: [PATCH] Fixed resource leak to scratch when _PyUnicodeWriter_Prepare fails --- Objects/longobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; }