diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-22 18:05:43 +0100 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-22 18:05:43 +0100 |
commit | af163af35cec8e23ddff613c208935e6cb3b5faa (patch) | |
tree | b196684e55a4367003999ae0e0988de56ad1b4d2 /Python/import.c | |
parent | afeaaa51caf909f9d81b835c52d9620755dc5033 (diff) | |
download | cpython-af163af35cec8e23ddff613c208935e6cb3b5faa.tar.gz |
Issue #14084: Fix a file descriptor leak when importing a module with a bad encoding.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/import.c b/Python/import.c index e5581c5bba..f443ab8511 100644 --- a/Python/import.c +++ b/Python/import.c @@ -3195,8 +3195,10 @@ call_find_module(char *name, PyObject *path) memory. */ found_encoding = PyTokenizer_FindEncoding(fd); lseek(fd, 0, 0); /* Reset position */ - if (found_encoding == NULL && PyErr_Occurred()) + if (found_encoding == NULL && PyErr_Occurred()) { + close(fd); return NULL; + } encoding = (found_encoding != NULL) ? found_encoding : (char*)PyUnicode_GetDefaultEncoding(); } |