Issue 28408: Fix redundant code and memory leak in _PyUnicodeWriter_Finish (original) (raw)

Issue28408

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/72594

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 2022-04-11 14:58 by admin. 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
2022-04-11 14:58:38 admin set github: 72594
2016-10-25 10:49:25 serhiy.storchaka set status: open -> closedresolution: fixedstage: commit review -> resolved
2016-10-25 10:48:21 python-dev set nosy: + python-devmessages: +
2016-10-25 10:21:14 serhiy.storchaka set messages: + versions: - Python 3.5
2016-10-25 10:14:52 serhiy.storchaka set assignee: serhiy.storchakamessages: + stage: patch review -> commit review
2016-10-10 17:13:36 xiang.zhang create

Supported by The Python Software Foundation,
Powered by Roundup

Copyright © 1990-2022, Python Software Foundation
Legal Statements