Skip to content

Commit 92ecb62

Browse files
committed
bpo-46881: Fix refleak from pythonGH-31616
@fidgetSpinner found the leak and the patch but asked me to submit it. Confirmed that this fixes the leak with ./python.exe -m test test_sax -R 3:2
1 parent 4052dd2 commit 92ecb62

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Objects/unicodeobject.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,12 @@ unicode_result_ready(PyObject *unicode)
677677
if (kind == PyUnicode_1BYTE_KIND) {
678678
const Py_UCS1 *data = PyUnicode_1BYTE_DATA(unicode);
679679
Py_UCS1 ch = data[0];
680-
if (unicode != LATIN1(ch)) {
680+
PyObject *latin1_char = LATIN1(ch);
681+
if (unicode != latin1_char) {
682+
Py_INCREF(latin1_char);
681683
Py_DECREF(unicode);
682684
}
683-
return get_latin1_char(ch);
685+
return latin1_char;
684686
}
685687
}
686688

0 commit comments

Comments
 (0)