diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2022-03-11 09:05:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-11 09:05:08 (GMT) |
commit | 54ab9ad312ea53db40e31712454272e1d4c0315f (patch) | |
tree | 944c78a4de813b520ad2d7c7b0651f780425ff38 | |
parent | b6a5d8590c4bfe4553d796b36af03bda8c0d5af5 (diff) | |
download | cpython-54ab9ad312ea53db40e31712454272e1d4c0315f.zip cpython-54ab9ad312ea53db40e31712454272e1d4c0315f.tar.gz cpython-54ab9ad312ea53db40e31712454272e1d4c0315f.tar.bz2 |
bpo-46881: Fix refleak from GH-31616 (GH-31805)
-rw-r--r-- | Objects/unicodeobject.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 9052c53..2261b9a 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -677,10 +677,12 @@ unicode_result_ready(PyObject *unicode) if (kind == PyUnicode_1BYTE_KIND) { const Py_UCS1 *data = PyUnicode_1BYTE_DATA(unicode); Py_UCS1 ch = data[0]; - if (unicode != LATIN1(ch)) { + PyObject *latin1_char = LATIN1(ch); + if (unicode != latin1_char) { + Py_INCREF(latin1_char); Py_DECREF(unicode); } - return get_latin1_char(ch); + return latin1_char; } } |