mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-130052: Fix search_map_for_section() error handling (#132594)
* Don't call close() if the file descriptor is negative. * If close() fails, chain the existing exception.
This commit is contained in:
parent
7dcaebfb21
commit
014c7f9047
1 changed files with 3 additions and 1 deletions
|
@ -400,8 +400,10 @@ search_map_for_section(pid_t pid, const char* secname, const char* map)
|
|||
}
|
||||
|
||||
exit:
|
||||
if (close(fd) != 0) {
|
||||
if (fd >= 0 && close(fd) != 0) {
|
||||
PyObject *exc = PyErr_GetRaisedException();
|
||||
PyErr_SetFromErrno(PyExc_OSError);
|
||||
_PyErr_ChainExceptions1(exc);
|
||||
}
|
||||
if (file_memory != NULL) {
|
||||
munmap(file_memory, file_stats.st_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue