Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 75176:cbfd2bf80db0 3.2
Issue #14084: Fix a file descriptor leak when importing a module with a bad encoding.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Wed, 22 Feb 2012 18:05:43 +0100 |
| parents | 963a0fba98e0 |
| children | daed636a3536 fcd0a67e708e |
line wrap: on
line diff
--- a/Python/import.c Wed Feb 22 18:03:04 2012 +0100 +++ b/Python/import.c Wed Feb 22 18:05:43 2012 +0100 @@ -3195,8 +3195,10 @@ 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(); }
