aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Drake <cygwin@jdrake.com>2025-04-02 12:55:57 -0700
committerJeremy Drake <cygwin@jdrake.com>2025-04-02 12:55:57 -0700
commitd1b4302ac64395fccde445026ecb147029340930 (patch)
tree1f92ca1b1d85b67cd81448358f8a313998d6e3c2
parentabc89b12e636beff1cdc6b713c77702459cd1523 (diff)
downloadnewlib-d1b4302ac64395fccde445026ecb147029340930.zip
newlib-d1b4302ac64395fccde445026ecb147029340930.tar.gz
newlib-d1b4302ac64395fccde445026ecb147029340930.tar.bz2
Cygwin: handle GetProcAddress returning NULL in GetArm64ProcAddress.
This was an oversight, the caller of GetArm64ProcAddress does check for a NULL return, but it would have crashed in the memcmp before getting there. Fixes: 2c5f25035d9f ("Cygwin: add find_fast_cwd_pointer_aarch64.") Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
-rw-r--r--winsup/cygwin/aarch64/fastcwd.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/winsup/cygwin/aarch64/fastcwd.cc b/winsup/cygwin/aarch64/fastcwd.cc
index a85c539..e53afc0 100644
--- a/winsup/cygwin/aarch64/fastcwd.cc
+++ b/winsup/cygwin/aarch64/fastcwd.cc
@@ -35,8 +35,8 @@ GetArm64ProcAddress (HMODULE hModule, LPCSTR procname)
#else
#error "Unhandled architecture for thunk detection"
#endif
- if (memcmp (proc, thunk, sizeof (thunk) - 1) == 0 ||
- (sizeof(thunk2) && memcmp (proc, thunk2, sizeof (thunk2) - 1) == 0))
+ if (proc && (memcmp (proc, thunk, sizeof (thunk) - 1) == 0 ||
+ (sizeof(thunk2) && memcmp (proc, thunk2, sizeof (thunk2) - 1) == 0)))
{
proc += sizeof (thunk) - 1;
proc += 4 + *(const int32_t *) proc;