mirror of
https://github.com/python/cpython.git
synced 2025-10-01 12:52:18 +00:00
bpo-32827: Fix usage of _PyUnicodeWriter_Prepare() in decoding errors handler. (GH-5636) (GH-5650)
(cherry picked from commit b7e2d67f7c
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
65c32bbe85
commit
09819ef05a
1 changed files with 3 additions and 7 deletions
|
@ -4256,7 +4256,7 @@ unicode_decode_call_errorhandler_writer(
|
||||||
}
|
}
|
||||||
if (need_to_grow) {
|
if (need_to_grow) {
|
||||||
writer->overallocate = 1;
|
writer->overallocate = 1;
|
||||||
if (_PyUnicodeWriter_Prepare(writer, writer->min_length,
|
if (_PyUnicodeWriter_Prepare(writer, writer->min_length - writer->pos,
|
||||||
PyUnicode_MAX_CHAR_VALUE(repunicode)) == -1)
|
PyUnicode_MAX_CHAR_VALUE(repunicode)) == -1)
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
|
@ -6085,9 +6085,7 @@ _PyUnicode_DecodeUnicodeEscape(const char *s,
|
||||||
&writer)) {
|
&writer)) {
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
if (_PyUnicodeWriter_Prepare(&writer, writer.min_length, 127) < 0) {
|
assert(end - s <= writer.size - writer.pos);
|
||||||
goto onError;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef WRITE_ASCII_CHAR
|
#undef WRITE_ASCII_CHAR
|
||||||
#undef WRITE_CHAR
|
#undef WRITE_CHAR
|
||||||
|
@ -6364,9 +6362,7 @@ PyUnicode_DecodeRawUnicodeEscape(const char *s,
|
||||||
&writer)) {
|
&writer)) {
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
if (_PyUnicodeWriter_Prepare(&writer, writer.min_length, 127) < 0) {
|
assert(end - s <= writer.size - writer.pos);
|
||||||
goto onError;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef WRITE_CHAR
|
#undef WRITE_CHAR
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue