[issue32827] Fix incorrect usage of _PyUnicodeWriter_Prepare()

Serhiy Storchaka report at bugs.python.org
Mon Feb 12 06:47:03 EST 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

Based on discussion in PR 660.

_PyUnicodeWriter_Prepare() is used incorrectly in unicode_decode_call_errorhandler_writer(), _PyUnicode_DecodeUnicodeEscape() and PyUnicode_DecodeRawUnicodeEscape() in Objects/unicodeobject.c. The second argument is the number of characters that should be reserved after the current position. But in these places the total minimal size is passed to _PyUnicodeWriter_Prepare(). This can lead to allocating more memory than necessary.

----------
components: Interpreter Core, Unicode
messages: 312038
nosy: ezio.melotti, serhiy.storchaka, vstinner, xiang.zhang
priority: normal
severity: normal
status: open
title: Fix incorrect usage of _PyUnicodeWriter_Prepare()
type: resource usage
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32827>
_______________________________________


More information about the Python-bugs-list mailing list