classification
Title: Fix redundant code and memory leak in _PyUnicodeWriter_Finish
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: python-dev, serhiy.storchaka, vstinner, xiang.zhang
Priority: normal Keywords: patch

Created on 2016-10-10 17:13 by xiang.zhang, last changed 2016-10-25 10:49 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
_PyUnicodeWriter_Finish.patch xiang.zhang, 2016-10-10 17:13 review
Messages (4)
msg278434 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-10-10 17:13
_PyUnicodeWriter_Finish gets 2 problems now:

1. It has two same branches handling empty strings which is redundant.

2. It may leak the inner buffer object when resize_compact fails. When resize_compact fails, the buffer object is left untouched. Then the writer itself is freed and the buffer is leaked.
msg279383 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-25 10:14
LGTM.
msg279385 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-25 10:21
3.5 is free from both problems. They were introduced in f33433d9c163.
msg279391 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-10-25 10:48
New changeset 9d618cebfc21 by Serhiy Storchaka in branch '3.6':
Issue #28408: Fixed a leak and remove redundant code in _PyUnicodeWriter_Finish().
https://hg.python.org/cpython/rev/9d618cebfc21

New changeset 24c3f997bd1a by Serhiy Storchaka in branch 'default':
Issue #28408: Fixed a leak and remove redundant code in _PyUnicodeWriter_Finish().
https://hg.python.org/cpython/rev/24c3f997bd1a
History
Date User Action Args
2016-10-25 10:49:25serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2016-10-25 10:48:21python-devsetnosy: + python-dev
messages: + msg279391
2016-10-25 10:21:14serhiy.storchakasetmessages: + msg279385
versions: - Python 3.5
2016-10-25 10:14:52serhiy.storchakasetassignee: serhiy.storchaka
messages: + msg279383
stage: patch review -> commit review
2016-10-10 17:13:36xiang.zhangcreate