From: Christian Heimes Date: Sun, 21 Jul 2013 14:19:02 +0000 (+0200) Subject: Fix reference and memory leaks in _freeze_importlib X-Git-Tag: v3.4.0a1~117^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=96f628f48797c0602e1421a42283740cc6ebfd67;p=thirdparty%2FPython%2Fcpython.git Fix reference and memory leaks in _freeze_importlib --- diff --git a/Modules/_freeze_importlib.c b/Modules/_freeze_importlib.c index 65b29e1f8c2a..b773c32537bd 100644 --- a/Modules/_freeze_importlib.c +++ b/Modules/_freeze_importlib.c @@ -72,6 +72,7 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) code = Py_CompileStringExFlags(text, "", Py_file_input, NULL, 0); + free(text); if (code == NULL) goto error; marshalled = PyMarshal_WriteObjectToString(code, Py_MARSHAL_VERSION); @@ -102,6 +104,7 @@ main(int argc, char *argv[]) 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);