summaryrefslogtreecommitdiffstats
path: root/Modules/_freeze_importlib.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-07-21 14:19:16 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-07-21 14:19:16 (GMT)
commit992fe2ab84cf9296cf04e128dedc16bcaaad8225 (patch)
tree670f2c16eec0ad171e2ec2192f1264406f816749 /Modules/_freeze_importlib.c
parentd786ad55ef7318d573cec7c57abe4f6d6c3a0439 (diff)
parent96f628f48797c0602e1421a42283740cc6ebfd67 (diff)
downloadcpython-992fe2ab84cf9296cf04e128dedc16bcaaad8225.zip
cpython-992fe2ab84cf9296cf04e128dedc16bcaaad8225.tar.gz
cpython-992fe2ab84cf9296cf04e128dedc16bcaaad8225.tar.bz2
Fix reference and memory leaks in _freeze_importlib
Diffstat (limited to 'Modules/_freeze_importlib.c')
-rw-r--r--Modules/_freeze_importlib.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/_freeze_importlib.c b/Modules/_freeze_importlib.c
index 0435a8a..75013e1 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, "<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 @@ 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);