From 89f9730f2b90e12b52fb59589e02400999643b8c Mon Sep 17 00:00:00 2001 From: Zeex Date: Sun, 1 Nov 2020 12:39:32 +0600 Subject: Fix possible NULL dereference --- subhook_x86.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'subhook_x86.c') diff --git a/subhook_x86.c b/subhook_x86.c index a6eb8bb..6256ebb 100644 --- a/subhook_x86.c +++ b/subhook_x86.c @@ -458,18 +458,16 @@ SUBHOOK_EXPORT subhook_t SUBHOOK_API subhook_new(void *src, subhook_t hook; int result; - hook = malloc(sizeof(*hook)); + hook = calloc(1, sizeof(*hook)); if (hook == NULL) { return NULL; } - hook->installed = 0; hook->src = src; hook->dst = dst; hook->flags = flags; hook->jmp_size = subhook_get_jmp_size(hook->flags); hook->trampoline_size = hook->jmp_size * 2 + MAX_INSN_LEN; - hook->trampoline_len = 0; hook->code = malloc(hook->jmp_size); if (hook->code == NULL) { -- cgit v1.1