aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Lu2016-10-23 22:19:56 -0700
committerYifan Lu2016-10-23 22:19:56 -0700
commit81dab3215635302fc9e2e2f3828092896aa4e6d9 (patch)
tree0a7519b32f845cf5f20de0da43ead1315aed0ee5
parentMoved cache flushing to an export (diff)
downloadsubstitute-81dab3215635302fc9e2e2f3828092896aa4e6d9.tar.gz
Forgot NULL pointer check
-rw-r--r--lib/hook-functions.c10
1 files 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};