[Python-checkins] cpython: Fixed resource leak to scratch when _PyUnicodeWriter_Prepare fails

christian.heimes python-checkins at python.org
Mon Sep 10 02:51:45 CEST 2012


http://hg.python.org/cpython/rev/1349e9537f91
changeset:   78936:1349e9537f91
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Sep 10 02:51:27 2012 +0200
summary:
  Fixed resource leak to scratch when _PyUnicodeWriter_Prepare fails

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


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

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


More information about the Python-checkins mailing list