]> granicus.if.org Git - python/commitdiff
Fixed memory leak in error branch of formatfloat(). CID 719687
authorChristian Heimes <christian@cheimes.de>
Mon, 10 Sep 2012 09:48:41 +0000 (11:48 +0200)
committerChristian Heimes <christian@cheimes.de>
Mon, 10 Sep 2012 09:48:41 +0000 (11:48 +0200)
Objects/unicodeobject.c

index 279516809f98a102ba01910dd9a10398a6dd7ef2..2d74d1cca3bbd2fc229e49d7f1e8c191961c24c3 100644 (file)
@@ -13238,8 +13238,10 @@ formatfloat(PyObject *v, int flags, int prec, int type,
         return -1;
     len = strlen(p);
     if (writer) {
-        if (_PyUnicodeWriter_Prepare(writer, len, 127) == -1)
+        if (_PyUnicodeWriter_Prepare(writer, len, 127) == -1) {
+            PyMem_Free(p);
             return -1;
+        }
         unicode_write_cstr(writer->buffer, writer->pos, p, len);
         writer->pos += len;
     }