Commit af163af3 authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #14084: Fix a file descriptor leak when importing a module with a bad encoding.

parent afeaaa51
...@@ -10,6 +10,9 @@ What's New in Python 3.2.3? ...@@ -10,6 +10,9 @@ What's New in Python 3.2.3?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #14084: Fix a file descriptor leak when importing a module with a
bad encoding.
- Issue #13703: oCERT-2011-003: add -R command-line option and PYTHONHASHSEED - Issue #13703: oCERT-2011-003: add -R command-line option and PYTHONHASHSEED
environment variable, to provide an opt-in way to protect against denial of environment variable, to provide an opt-in way to protect against denial of
service attacks due to hash collisions within the dict and set types. Patch service attacks due to hash collisions within the dict and set types. Patch
......
...@@ -3195,8 +3195,10 @@ call_find_module(char *name, PyObject *path) ...@@ -3195,8 +3195,10 @@ call_find_module(char *name, PyObject *path)
memory. */ memory. */
found_encoding = PyTokenizer_FindEncoding(fd); found_encoding = PyTokenizer_FindEncoding(fd);
lseek(fd, 0, 0); /* Reset position */ lseek(fd, 0, 0); /* Reset position */
if (found_encoding == NULL && PyErr_Occurred()) if (found_encoding == NULL && PyErr_Occurred()) {
close(fd);
return NULL; return NULL;
}
encoding = (found_encoding != NULL) ? found_encoding : encoding = (found_encoding != NULL) ? found_encoding :
(char*)PyUnicode_GetDefaultEncoding(); (char*)PyUnicode_GetDefaultEncoding();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment