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.
I didn't know Py_FrozenMain(). I upgraded it to use the same code than main(). Should I backport my fixes to Python 3.3 (except maybe 0001c4100823 which is risky).
> Victor, is here anything left to do? The bug is correctly fixed in default. I don't really care of fixing such warning of static analyzer in older Python versions. It's more a theorical bug, it's a small memory leak and only occur if another error occurs. I just close the issue.