[Python-checkins] cpython (merge 3.3 -> default): Fix reference and memory leaks in _freeze_importlib

christian.heimes python-checkins at python.org
Sun Jul 21 16:23:12 CEST 2013


http://hg.python.org/cpython/rev/c18bb06892e9
changeset:   84763:c18bb06892e9
parent:      84761:276477d5a548
parent:      84762:eb76c4201e56
user:        Christian Heimes <christian at cheimes.de>
date:        Sun Jul 21 16:19:16 2013 +0200
summary:
  Fix reference and memory leaks in _freeze_importlib

files:
  Modules/_freeze_importlib.c |  3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)


diff --git a/Modules/_freeze_importlib.c b/Modules/_freeze_importlib.c
--- a/Modules/_freeze_importlib.c
+++ b/Modules/_freeze_importlib.c
@@ -72,6 +72,7 @@
     if (n < text_size) {
         fprintf(stderr, "read too short: got %ld instead of %ld bytes\n",
                 (long) n, (long) text_size);
+        free(text);
         return 1;
     }
     text[text_size] = '\0';
@@ -86,6 +87,7 @@
 
     code = Py_CompileStringExFlags(text, "<frozen importlib._bootstrap>",
                                    Py_file_input, NULL, 0);
+    free(text);
     if (code == NULL)
         goto error;
     marshalled = PyMarshal_WriteObjectToString(code, Py_MARSHAL_VERSION);
@@ -102,6 +104,7 @@
     outfile = fopen(outpath, "w");
     if (outfile == NULL) {
         fprintf(stderr, "cannot open '%s' for writing\n", outpath);
+        Py_DECREF(marshalled);
         return 1;
     }
     fprintf(outfile, "%s\n", header);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list