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

index 6b8033ecf8ccbab6175c5028a20540ec4bb17860..e584accf720c7cccc95ec028fd05bfe7a8f5bdd4 100644 (file)
@@ -890,8 +890,10 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
                 ressize += 1+1+2;
         }
         res = PyUnicode_New(ressize, 127);
-        if (res==NULL)
+        if (res == NULL) {
+            Py_DECREF(object);
             return NULL;
+        }
         for (i = start, outp = PyUnicode_1BYTE_DATA(res);
             i < end; ++i) {
             c = PyUnicode_READ_CHAR(object, i);