Issue #23321: Fixed a crash in str.decode() when error handler returned
replacment string longer than mailformed input data.
This commit is contained in:
commit
bbd3aa8ece
|
@ -10,6 +10,9 @@ Release date: TBA
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #23321: Fixed a crash in str.decode() when error handler returned
|
||||||
|
replacment string longer than mailformed input data.
|
||||||
|
|
||||||
- Issue #22286: The "backslashreplace" error handlers now works with
|
- Issue #22286: The "backslashreplace" error handlers now works with
|
||||||
decoding and translating.
|
decoding and translating.
|
||||||
|
|
||||||
|
|
|
@ -4155,9 +4155,13 @@ unicode_decode_call_errorhandler_writer(
|
||||||
if (PyUnicode_READY(repunicode) < 0)
|
if (PyUnicode_READY(repunicode) < 0)
|
||||||
goto onError;
|
goto onError;
|
||||||
replen = PyUnicode_GET_LENGTH(repunicode);
|
replen = PyUnicode_GET_LENGTH(repunicode);
|
||||||
writer->min_length += replen;
|
if (replen > 1) {
|
||||||
if (replen > 1)
|
writer->min_length += replen - 1;
|
||||||
writer->overallocate = 1;
|
writer->overallocate = 1;
|
||||||
|
if (_PyUnicodeWriter_Prepare(writer, writer->min_length,
|
||||||
|
PyUnicode_MAX_CHAR_VALUE(repunicode)) == -1)
|
||||||
|
goto onError;
|
||||||
|
}
|
||||||
if (_PyUnicodeWriter_WriteStr(writer, repunicode) == -1)
|
if (_PyUnicodeWriter_WriteStr(writer, repunicode) == -1)
|
||||||
goto onError;
|
goto onError;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue