mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Issue #16971: Fix a refleak in the charmap decoder.
This commit is contained in:
parent
1e49dde2d9
commit
afb1cb5579
1 changed files with 13 additions and 4 deletions
|
@ -7510,14 +7510,18 @@ Error:
|
||||||
Py_DECREF(x);
|
Py_DECREF(x);
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
if (unicode_putchar(&v, &outpos, value) < 0)
|
if (unicode_putchar(&v, &outpos, value) < 0) {
|
||||||
|
Py_DECREF(x);
|
||||||
goto onError;
|
goto onError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (PyUnicode_Check(x)) {
|
else if (PyUnicode_Check(x)) {
|
||||||
Py_ssize_t targetsize;
|
Py_ssize_t targetsize;
|
||||||
|
|
||||||
if (PyUnicode_READY(x) == -1)
|
if (PyUnicode_READY(x) == -1) {
|
||||||
|
Py_DECREF(x);
|
||||||
goto onError;
|
goto onError;
|
||||||
|
}
|
||||||
targetsize = PyUnicode_GET_LENGTH(x);
|
targetsize = PyUnicode_GET_LENGTH(x);
|
||||||
|
|
||||||
if (targetsize == 1) {
|
if (targetsize == 1) {
|
||||||
|
@ -7525,8 +7529,10 @@ Error:
|
||||||
Py_UCS4 value = PyUnicode_READ_CHAR(x, 0);
|
Py_UCS4 value = PyUnicode_READ_CHAR(x, 0);
|
||||||
if (value == 0xFFFE)
|
if (value == 0xFFFE)
|
||||||
goto Undefined;
|
goto Undefined;
|
||||||
if (unicode_putchar(&v, &outpos, value) < 0)
|
if (unicode_putchar(&v, &outpos, value) < 0) {
|
||||||
|
Py_DECREF(x);
|
||||||
goto onError;
|
goto onError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (targetsize > 1) {
|
else if (targetsize > 1) {
|
||||||
/* 1-n mapping */
|
/* 1-n mapping */
|
||||||
|
@ -7543,8 +7549,11 @@ Error:
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unicode_widen(&v, outpos, PyUnicode_MAX_CHAR_VALUE(x)) < 0)
|
if (unicode_widen(&v, outpos,
|
||||||
|
PyUnicode_MAX_CHAR_VALUE(x)) < 0) {
|
||||||
|
Py_DECREF(x);
|
||||||
goto onError;
|
goto onError;
|
||||||
|
}
|
||||||
PyUnicode_CopyCharacters(v, outpos, x, 0, targetsize);
|
PyUnicode_CopyCharacters(v, outpos, x, 0, targetsize);
|
||||||
outpos += targetsize;
|
outpos += targetsize;
|
||||||
extrachars -= targetsize;
|
extrachars -= targetsize;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue