]> sourceware.org Git - newlib-cygwin.git/commit
Cygwin: cwd: avoid releasing the cwdstuff SRW Lock twice
authorCorinna Vinschen <corinna@vinschen.de>
Mon, 30 Oct 2023 18:40:31 +0000 (19:40 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 31 Oct 2023 09:52:02 +0000 (10:52 +0100)
commitf0c90d3a8aa4409608abe76e035eab5919133a61
tree641c1331ec6254b7003fbf82fac553d1a477b348
parent386e762aa140a18c4bc3fd5963c4bbc6e2663c76
Cygwin: cwd: avoid releasing the cwdstuff SRW Lock twice

cwdstuff::set has a code snippet handling the case where a process
can't create a handle to a directory, e. g., due to permissions.

Commit 88443b0a22589 ("cwdstuff: Don't leave from setting the CWD
prematurely on init") introduced a special case to handle this
situation at process initialization. It also introduces an early
mutex release, which is not required, but ok, because we're in the
init phase. Releasing the mutex twice is no problem since the mutexes
are recursive.

Fast forward to commit 0819679a7a210 ("Cygwin: cwd: use SRWLOCK
instead of muto"). The mechanical change from a recursive mutex
to a non-recursive SRWLOCK failed to notice that this very specific
situation will release the SRWLOCK twice.

Remove the superfluous release action. While at it, don't set dir to
NULL, but h, since dir will get the value of h anyway later on.
Setting h to NULL may not be necessary, but better safe than sorry.

Reported-by: tryandbuy >tryandbuy@proton.me>
Fixes: 88443b0a22589 ("cwdstuff: Don't leave from setting the CWD prematurely on init")
Fixes: 0819679a7a210 ("Cygwin: cwd: use SRWLOCK instead of muto")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/path.cc
winsup/cygwin/release/3.4.10
This page took 0.032118 seconds and 5 git commands to generate.