[newlib-cygwin] Cygwin: open: Add missing unlock on error
Takashi Yano
tyan0@sourceware.org
Mon Aug 3 10:49:34 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0d3ea0ee653f63e50c66c444e8059256d72f03bf
commit 0d3ea0ee653f63e50c66c444e8059256d72f03bf
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Mon Aug 3 12:11:20 2026 +0900
Cygwin: open: Add missing unlock on error
the commit 524d75ff7398 ("Cygwin: open: Unlock fdtab before open_
with_arch()") introduced a bug that fdtab lock was not unlocked
when new fd cannot be allocated due to an error.
This patch adds missing unlock for fdtab lock on error.
Fixes: 524d75ff7398 ("Cygwin: open: Unlock fdtab before open_with_arch()")
Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Mark Geisert <mark@maxrnd.com>
Diff:
---
winsup/cygwin/syscalls.cc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index e3ba8c65c..5465d6c09 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1554,7 +1554,10 @@ open (const char *unix_path, int flags, ...)
cygheap->fdtab.lock();
fd = cygheap->fdtab.find_unused_handle ();
if (fd < 0)
- __leave; /* errno already set */
+ {
+ cygheap->fdtab.unlock ();
+ __leave; /* errno already set */
+ }
cygheap->fdtab[fd] = fh; /* tentative setting to mark as used */
cygheap->fdtab.unlock();
More information about the Cygwin-cvs
mailing list