[Python-checkins] bpo-32827: Fix usage of _PyUnicodeWriter_Prepare() in decoding errors handler. (GH-5636) (GH-5650)

Serhiy Storchaka webhook-mailer at python.org
Tue Feb 13 02:16:00 EST 2018


https://github.com/python/cpython/commit/09819ef05a9a1b13321b56c09f48ca45b46e8656
commit: 09819ef05a9a1b13321b56c09f48ca45b46e8656
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2018年02月13日T09:15:57+02:00
summary:
bpo-32827: Fix usage of _PyUnicodeWriter_Prepare() in decoding errors handler. (GH-5636) (GH-5650)
(cherry picked from commit b7e2d67f7c035f09c921ca4e7a36529cd502ccf7)
Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>
files:
M Objects/unicodeobject.c
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 3d9e09d7fab1..d5e7d10b1759 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -4256,7 +4256,7 @@ unicode_decode_call_errorhandler_writer(
 }
 if (need_to_grow) {
 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)
 goto onError;
 }
@@ -6085,9 +6085,7 @@ _PyUnicode_DecodeUnicodeEscape(const char *s,
 &writer)) {
 goto onError;
 }
- if (_PyUnicodeWriter_Prepare(&writer, writer.min_length, 127) < 0) {
- goto onError;
- }
+ assert(end - s <= writer.size - writer.pos);
 
 #undef WRITE_ASCII_CHAR
 #undef WRITE_CHAR
@@ -6364,9 +6362,7 @@ PyUnicode_DecodeRawUnicodeEscape(const char *s,
 &writer)) {
 goto onError;
 }
- if (_PyUnicodeWriter_Prepare(&writer, writer.min_length, 127) < 0) {
- goto onError;
- }
+ assert(end - s <= writer.size - writer.pos);
 
 #undef WRITE_CHAR
 }


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /