mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
Issue #14084: Fix a file descriptor leak when importing a module with a bad encoding.
This commit is contained in:
commit
cf1c8339f9
2 changed files with 6 additions and 4 deletions
|
@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #14084: Fix a file descriptor leak when importing a module with a
|
||||||
|
bad encoding.
|
||||||
|
|
||||||
- Upgrade Unicode data to Unicode 6.1.
|
- Upgrade Unicode data to Unicode 6.1.
|
||||||
|
|
||||||
- Issue #14040: Remove rarely used file name suffixes for C extensions
|
- Issue #14040: Remove rarely used file name suffixes for C extensions
|
||||||
|
|
|
@ -3628,11 +3628,9 @@ call_find_module(PyObject *name, PyObject *path_list)
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
fd = dup(fd);
|
fd = dup(fd);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (fd == -1) {
|
|
||||||
PyErr_SetFromErrno(PyExc_OSError);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
|
if (fd == -1)
|
||||||
|
return PyErr_SetFromErrno(PyExc_OSError);
|
||||||
}
|
}
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
if (strchr(fdp->mode, 'b') == NULL) {
|
if (strchr(fdp->mode, 'b') == NULL) {
|
||||||
|
@ -3642,6 +3640,7 @@ call_find_module(PyObject *name, PyObject *path_list)
|
||||||
lseek(fd, 0, 0); /* Reset position */
|
lseek(fd, 0, 0); /* Reset position */
|
||||||
if (found_encoding == NULL && PyErr_Occurred()) {
|
if (found_encoding == NULL && PyErr_Occurred()) {
|
||||||
Py_XDECREF(pathobj);
|
Py_XDECREF(pathobj);
|
||||||
|
close(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
encoding = (found_encoding != NULL) ? found_encoding :
|
encoding = (found_encoding != NULL) ? found_encoding :
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue