mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #14084: Fix a file descriptor leak when importing a module with a bad encoding.
This commit is contained in:
parent
7214612443
commit
4f22a8d739
2 changed files with 6 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue