From 81dab3215635302fc9e2e2f3828092896aa4e6d9 Mon Sep 17 00:00:00 2001 From: Yifan Lu Date: Sun, 23 Oct 2016 22:19:56 -0700 Subject: Forgot NULL pointer check --- lib/hook-functions.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/hook-functions.c b/lib/hook-functions.c index f59126a..1c96d61 100644 --- a/lib/hook-functions.c +++ b/lib/hook-functions.c @@ -292,10 +292,12 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks, fws[i].src = hi->jump_patch; fws[i].len = hi->jump_patch_size; fws[i].opt = hooks[i].opt; - records->function = hi->code; - records->buffer_size = hi->jump_patch_size; - memcpy(records->saved_buffer, hi->code, hi->jump_patch_size); - records = (struct substitute_function_hook_record *)((char *)&records->saved_buffer + records->buffer_size); + if (records) { + records->function = hi->code; + records->buffer_size = hi->jump_patch_size; + memcpy(records->saved_buffer, hi->code, hi->jump_patch_size); + records = (struct substitute_function_hook_record *)((char *)&records->saved_buffer + records->buffer_size); + } } struct pc_callback_info info = {his, nhooks, false}; -- cgit v1.2.3