]> granicus.if.org Git - python/commitdiff
If main() is called and an argument cannot be decoded, make sure to
authorBrett Cannon <brett@python.org>
Mon, 25 Jun 2012 20:25:28 +0000 (16:25 -0400)
committerBrett Cannon <brett@python.org>
Mon, 25 Jun 2012 20:25:28 +0000 (16:25 -0400)
free the copy of the command-line.

Found using Clang's static analyzer.

Misc/NEWS
Modules/python.c

index 071b63b5ff526f4248f01f8cd67f733fa870ed15..724540b45402473841f5fa929c57a13a3d39be50 100644 (file)
--- 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.
 
index cf9383f444ed9be30ba5beaf6ea121cb78e2ee26..c70bf37827913da623f4a3303d86f288073ed864 100644 (file)
@@ -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);