[Python-checkins] cpython: Fixed memory leak in error branch of formatfloat(). CID 719687

georg.brandl python-checkins at python.org
Mon Sep 24 07:47:18 CEST 2012


http://hg.python.org/cpython/rev/d000fb73153e
changeset:   79126:d000fb73153e
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Sep 10 11:48:41 2012 +0200
summary:
  Fixed memory leak in error branch of formatfloat(). CID 719687

files:
  Objects/unicodeobject.c |  4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13237,8 +13237,10 @@
         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;
     }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list