[Python-checkins] cpython (2.7): Fixed reference leak in the "backslashreplace" error handler.

serhiy.storchaka python-checkins at python.org
Tue Sep 23 19:03:06 CEST 2014


https://hg.python.org/cpython/rev/49e293fb36fe
changeset:   92533:49e293fb36fe
branch:      2.7
parent:      92528:66e6807442c9
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Sep 23 19:58:57 2014 +0300
summary:
  Fixed reference leak in the "backslashreplace" error handler.

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


diff --git a/Python/codecs.c b/Python/codecs.c
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -696,8 +696,10 @@
                 ressize += 1+1+2;
         }
         res = PyUnicode_FromUnicode(NULL, ressize);
-        if (res==NULL)
+        if (res == NULL) {
+            Py_DECREF(object);
             return NULL;
+        }
         for (p = startp+start, outp = PyUnicode_AS_UNICODE(res);
             p < startp+end; ++p) {
             Py_UNICODE c = *p;

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


More information about the Python-checkins mailing list