From f1e005d63bfb0245969bad46ff13523ec00dd1c6 Mon Sep 17 00:00:00 2001 From: Yifan Lu Date: Wed, 5 Oct 2016 23:08:44 -0700 Subject: Changed malloc in substitute_hook_functions to alloca --- lib/hook-functions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hook-functions.c b/lib/hook-functions.c index a39cbb0..d7b925f 100644 --- a/lib/hook-functions.c +++ b/lib/hook-functions.c @@ -5,6 +5,7 @@ #include "transform-dis.h" #include "execmem.h" #include stringify(TARGET_DIR/jump-patch.h) +#include #ifndef NO_PTHREADS #include #endif @@ -149,7 +150,7 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks, *recordp = NULL; struct execmem_foreign_write *fws; - struct hook_internal *his = malloc(nhooks * sizeof(*his) + + struct hook_internal *his = alloca(nhooks * sizeof(*his) + nhooks * sizeof(*fws)); if (!his) return SUBSTITUTE_ERR_OOM; @@ -297,7 +298,6 @@ end: execmem_free(page); } end_dont_free: - free(his); return ret; } -- cgit v1.2.3