From 063df0fd5c82194a8579a4ea6c8700a0b22642cb Mon Sep 17 00:00:00 2001 From: Zeex Date: Wed, 11 Nov 2020 01:53:05 +0600 Subject: Make subhook_new() not fail on any trampoline-related error --- subhook_x86.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/subhook_x86.c b/subhook_x86.c index 53f3c02..d9a26d6 100644 --- a/subhook_x86.c +++ b/subhook_x86.c @@ -488,23 +488,18 @@ SUBHOOK_EXPORT subhook_t SUBHOOK_API subhook_new(void *src, } hook->trampoline = subhook_alloc_code(hook->trampoline_size); - if (hook->trampoline == NULL) { - goto error_exit; - } - - error = subhook_make_trampoline( - hook->trampoline, - hook->src, - hook->jmp_size, - &hook->trampoline_len, - hook->flags); - if (error != 0 && error != -EOVERFLOW) { - goto error_exit; - } - - if (hook->trampoline_len == 0) { - subhook_free_code(hook->trampoline, hook->trampoline_size); - hook->trampoline = NULL; + if (hook->trampoline != NULL) { + error = subhook_make_trampoline(hook->trampoline, + hook->src, + hook->jmp_size, + &hook->trampoline_len, + hook->flags); + if (error != 0) { + subhook_free_code(hook->trampoline, hook->trampoline_size); + hook->trampoline = NULL; + hook->trampoline_size = 0; + hook->trampoline_len = 0; + } } return hook; -- cgit v1.1