Issue 36367: tokenizer.c memory leak in case of realloc failure (original) (raw)

Issue36367

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/80548

classification

Title: tokenizer.c memory leak in case of realloc failure
Type: Stage: resolved
Components: Versions: Python 3.8, Python 3.7, Python 2.7

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cstratak, pablogsal, vstinner
Priority: normal Keywords: patch

Created on 2019-03-19 16:12 by cstratak, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12442 merged pablogsal,2019-03-19 16:18
PR 12470 merged vstinner,2019-03-20 11:22
PR 12471 merged vstinner,2019-03-20 11:25
Messages (4)
msg338375 - (view) Author: Charalampos Stratakis (cstratak) * Date: 2019-03-19 16:12
In tokenizer.c we have those lines of code [0]: if (final_length < needed_length && final_length) /* should never fail */ buf = PyMem_REALLOC(buf, final_length); return buf; If however that realloc fails, the memory allocated initially for buf, will not be freed. [0] https://github.com/python/cpython/blob/master/Parser/tokenizer.c#L652
msg338391 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-03-19 17:18
New changeset cb90c89de14aab636739b3e810cf949e47b54a0c by Pablo Galindo in branch 'master': bpo-36367: Free buffer if realloc fails in tokenize.c (GH-12442) https://github.com/python/cpython/commit/cb90c89de14aab636739b3e810cf949e47b54a0c
msg338459 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-03-20 12:03
New changeset 65b9849f0f07a000d751c96d9d711aeb24c95224 by Victor Stinner in branch '3.7': bpo-36367: Free buffer if realloc fails in tokenize.c (GH-12442) (GH-12471) https://github.com/python/cpython/commit/65b9849f0f07a000d751c96d9d711aeb24c95224
msg338460 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-03-20 12:03
New changeset 469b0a50d990bcb441910b23194c131e403c2833 by Victor Stinner in branch '2.7': bpo-36367: Free buffer if realloc fails in tokenize.c (GH-12442) (GH-12470) https://github.com/python/cpython/commit/469b0a50d990bcb441910b23194c131e403c2833
History
Date User Action Args
2022-04-11 14:59:12 admin set github: 80548
2019-03-20 12:03:56 vstinner set versions: + Python 2.7, Python 3.7, Python 3.8
2019-03-20 12:03:43 vstinner set messages: +
2019-03-20 12:03:18 vstinner set nosy: + vstinnermessages: +
2019-03-20 11:25:00 vstinner set pull_requests: + <pull%5Frequest12423>
2019-03-20 11:22:14 vstinner set pull_requests: + <pull%5Frequest12422>
2019-03-19 17🔞20 pablogsal set status: open -> closedresolution: fixedstage: patch review -> resolved
2019-03-19 17🔞05 pablogsal set nosy: + pablogsalmessages: +
2019-03-19 16🔞55 pablogsal set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest12397>
2019-03-19 16:12:41 cstratak create