[newlib-cygwin] Cygwin: handle GetProcAddress returning NULL in GetArm64ProcAddress.

Jeremy Drake jeremyd2019@sourceware.org
Wed Apr 2 20:33:23 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d1b4302ac64395fccde445026ecb147029340930

commit d1b4302ac64395fccde445026ecb147029340930
Author: Jeremy Drake <cygwin@jdrake.com>
Date:   Wed Apr 2 12:55:57 2025 -0700

    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>

Diff:
---
 winsup/cygwin/aarch64/fastcwd.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/aarch64/fastcwd.cc b/winsup/cygwin/aarch64/fastcwd.cc
index a85c53981..e53afc004 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;


More information about the Cygwin-cvs mailing list