From 7d96a09aca160f721820c2a63fcd3bfe100c050e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 23 Sep 2014 19:58:57 +0300 Subject: [PATCH] Fixed reference leak in the "backslashreplace" error handler. --- Python/codecs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/codecs.c b/Python/codecs.c index 69498c4b0c..7d1145f193 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -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; -- 2.50.1