diff options
| author | Igor Podgainoi <Igor.Podgainoi@arm.com> | 2026-02-18 09:43:41 +0000 |
|---|---|---|
| committer | Corinna Vinschen <corinna@vinschen.de> | 2026-03-02 20:39:16 +0100 |
| commit | 335c25cc2b9208b77f8a2d39634ec3983a6a8e6c (patch) | |
| tree | 6b32a14ff0ebdf9fd5e6865b15ba4bcea6d7695d /libgloss/write.c | |
| parent | 3f4ae584b2b05a968bad0598b03ca83245320af3 (diff) | |
| download | newlib-github/master.zip newlib-github/master.tar.gz newlib-github/master.tar.bz2 | |
Cygwin: open: Fix Windows resource leak after fd exhaustionHEADgithub/mastergithub/mainmastermain
In a specific rare case when a Cygwin process runs out of available
file descriptor numbers (errno set to EMFILE), the underlying Windows
HANDLE is not being closed. This is partly because currently the given
file is first opened natively before a new Cygwin file descriptor has
been assigned - the logic overlooks the fact that it is possible for
the Windows HANDLE to be valid, but not the internal fd.
Even though the object is explicitly freed from memory later using
operator delete, the fhandler_disk_file class has no destructor
defined to mitigate the leak.
This patch introduces a manual call to fh->close() if the assigned fd
value returned by the operator int &() function in the cygheap_fdnew
class is less than 0.
Test fixed on AArch64 and x86_64:
winsup.api/ltp/dup03.exe
Signed-off-by: Igor Podgainoi <Igor.Podgainoi@arm.com>
Diffstat (limited to 'libgloss/write.c')
0 files changed, 0 insertions, 0 deletions
