]> granicus.if.org Git - python/commitdiff
Fixed reference leak in the "backslashreplace" error handler.
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 23 Sep 2014 16:58:57 +0000 (19:58 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 23 Sep 2014 16:58:57 +0000 (19:58 +0300)
Python/codecs.c

index 69498c4b0c95de03e5b15f411febde26fa1d0d94..7d1145f19369d236a943cc10b7b596846dbcbfe9 100644 (file)
@@ -696,8 +696,10 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
                 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;