From 0b1b9ce494ee91ed525a83b802e15cd9a03922d5 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Mon, 25 Jun 2012 16:25:28 -0400 Subject: 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. --- Misc/NEWS | 3 +++ Modules/python.c | 1 + 2 files changed, 4 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 071b63b..724540b 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.3.0 Beta 1? Core and Builtins ----------------- +- Fix a (most likely) very rare memory leak when calling main() and not being + able to decode a command-line argument. + - Issue #14815: Use Py_ssize_t instead of long for the object hash, to preserve all 64 bits of hash on Win64. diff --git a/Modules/python.c b/Modules/python.c index cf9383f..c70bf37 100644 --- a/Modules/python.c +++ b/Modules/python.c @@ -51,6 +51,7 @@ main(int argc, char **argv) argv_copy[i] = _Py_char2wchar(argv[i], NULL); #endif if (!argv_copy[i]) { + free(oldloc); fprintf(stderr, "Fatal Python error: " "unable to decode the command line argument #%i\n", i + 1); -- cgit v0.12