Fixed reference leak in the "backslashreplace" error handler.

This commit is contained in:
Serhiy Storchaka 2014-09-23 19:59:09 +03:00
parent eb83ffe1b3
commit 8aa8c47db2
1 changed files with 3 additions and 1 deletions

View 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);