aboutsummaryrefslogtreecommitdiff
path: root/subhook_x86.c
diff options
context:
space:
mode:
Diffstat (limited to 'subhook_x86.c')
-rw-r--r--subhook_x86.c29
1 files 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;