From 098cd69ff9fe8f78753a86d0c17b0c87b0a13587 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 6 Mar 2007 12:17:50 +0000 Subject: Bug #1674503: close the file opened by execfile() in an error condition. --- Python/pythonrun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 98ae1151af..3d0c68f2a7 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1251,12 +1251,12 @@ PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, mod = PyParser_ASTFromFile(fp, filename, start, 0, 0, flags, NULL, arena); + if (closeit) + fclose(fp); if (mod == NULL) { PyArena_Free(arena); return NULL; } - if (closeit) - fclose(fp); ret = run_mod(mod, filename, globals, locals, flags, arena); PyArena_Free(arena); return ret; -- cgit v1.2.1