Skip to content

Commit cbcbfdf

Browse files
Fixed reference leak in the "backslashreplace" error handler.
2 parents 21df71a + 8aa8c47 commit cbcbfdf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Python/codecs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,8 +890,10 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
890890
ressize += 1+1+2;
891891
}
892892
res = PyUnicode_New(ressize, 127);
893-
if (res==NULL)
893+
if (res == NULL) {
894+
Py_DECREF(object);
894895
return NULL;
896+
}
895897
for (i = start, outp = PyUnicode_1BYTE_DATA(res);
896898
i < end; ++i) {
897899
c = PyUnicode_READ_CHAR(object, i);

0 commit comments

Comments
 (0)