Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b1b9ce

Browse files
committed
If main() is called and an argument cannot be decoded, make sure to
free the copy of the command-line. Found using Clang's static analyzer.
1 parent 8a250fa commit 0b1b9ce

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Beta 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Fix a (most likely) very rare memory leak when calling main() and not being
14+
able to decode a command-line argument.
15+
1316
- Issue #14815: Use Py_ssize_t instead of long for the object hash, to
1417
preserve all 64 bits of hash on Win64.
1518

Modules/python.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ main(int argc, char **argv)
5151
argv_copy[i] = _Py_char2wchar(argv[i], NULL);
5252
#endif
5353
if (!argv_copy[i]) {
54+
free(oldloc);
5455
fprintf(stderr, "Fatal Python error: "
5556
"unable to decode the command line argument #%i\n",
5657
i + 1);

0 commit comments

Comments
 (0)