[New-bugs-announce] [issue15893] Py_FrozenMain() resource leak and missing malloc checks

Christian Heimes report at bugs.python.org
Mon Sep 10 00:09:58 CEST 2012


New submission from Christian Heimes:

In Python/frozenmain.c the function Py_FrozenMain() doesn't handle argv_copy and argv_copy2 correctly. Both variables contain memory that is allocated with PyMem_Malloc(). argv_copy2 is never checked for NULL and both variables are not correctly cleaned up in error cases.

CID 486834: Resource leak (RESOURCE_LEAK)At (11): Variable "argv_copy" going out of scope leaks the storage it points to. 
CID 486835: Resource leak (RESOURCE_LEAK)At (9): Variable "argv_copy2" going out of scope leaks the storage it points to.

Suggested fix:
Separate var declaration from PyMem_Malloc() calls and use a goto label to clean up the variables and its content at the end of the function.

----------
components: Interpreter Core
messages: 170139
nosy: christian.heimes
priority: normal
severity: normal
status: open
title: Py_FrozenMain() resource leak and missing malloc checks
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15893>
_______________________________________


More information about the New-bugs-announce mailing list