From a596f2b117fe06540da3903c9a60e9d7882af6da Mon Sep 17 00:00:00 2001 From: Zeex Date: Mon, 2 Nov 2020 03:46:00 +0600 Subject: Add null check in subhok_free_code() --- subhook_unix.c | 3 +++ subhook_windows.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/subhook_unix.c b/subhook_unix.c index 48c6af2..d3616d7 100644 --- a/subhook_unix.c +++ b/subhook_unix.c @@ -52,5 +52,8 @@ void *subhook_alloc_code(size_t size) { } int subhok_free_code(void *address, size_t size) { + if (address == NULL) { + return 0; + } return munmap(address, size); } diff --git a/subhook_windows.c b/subhook_windows.c index b934651..bf6d2e9 100644 --- a/subhook_windows.c +++ b/subhook_windows.c @@ -47,5 +47,9 @@ void *subhook_alloc_code(size_t size) { int subhok_free_code(void *address, size_t size) { (void)size; + + if (address == NULL) { + return 0; + } return !VirtualFree(address, 0, MEM_RELEASE); } -- cgit v1.1