New submission from Lucas Cimon <lucas.ci...@gmail.com>:

Hi.

I think I have found a minor memory leak in 
Modules/main.c:pymain_parse_cmdline_impl.

When the loop in the pymain_read_conf function in this same file
calls pymain_init_cmdline_argv a 2nd time, the pymain->command
buffer of wchar_t is overriden and the previously allocated memory
is never freed.

I haven't written any code test to reproduce this,
but it can be tested easily with gdb:
```
gdb -- bin/python3 -c pass
start
b Modules/main.c:587
b pymain_clear_pymain
c
c
```
You'll see that PyMem_RawMalloc is called twice without pymain->command ever 
being freed in pymain_clear_pymain.

I have a patch coming as PR on GitHub

I'd be glad to have your feedback on this issue and my proposal for a fix.

Regards.

----------
messages: 333499
nosy: Lucas Cimon
priority: normal
severity: normal
status: open
title: Memory leak in Modules/main.c:pymain_parse_cmdline_impl when using the 
CLI flag

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35720>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to