]> granicus.if.org Git - python/commitdiff
Fixed resource leak to scratch when _PyUnicodeWriter_Prepare fails
authorChristian Heimes <christian@cheimes.de>
Mon, 10 Sep 2012 00:51:27 +0000 (02:51 +0200)
committerChristian Heimes <christian@cheimes.de>
Mon, 10 Sep 2012 00:51:27 +0000 (02:51 +0200)
Objects/longobject.c

index 80fe724d3455c3afe1bb72f5c437f7cb8bb6be29..7e12b3488484296f15ffe65d36c9b441891ed3dd 100644 (file)
@@ -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;
     }