On Apr  2 13:01, Jeremy Drake via Cygwin-patches wrote:
> 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 <cyg...@jdrake.com>
> ---
>  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 a85c539817..e53afc0046 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;
> -- 
> 2.48.1.windows.1

Yup, makes sense. Please push.

Thanks,
Corinna

Reply via email to