diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-08-06 12:19:45 -0300 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-08-06 12:19:45 -0300 |
commit | 19ee637cefbdc197c0d249b146f263116812db53 (patch) | |
tree | 1f3c7b38ca13eae4bd341341b7d0fb307c96399b | |
parent | 83b32144799ac58c845120ef901571869a3b3bc9 (diff) |
keyword: Fix a major issue with `get_keyword_offset_ptr()` adding the
offset before dereferencing `ret`, and also check if the dereferenced
return pointer is NULL
-rw-r--r-- | keyword.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -13,7 +13,11 @@ void *get_keyword_offset_ptr(const keyword *key, void *ptr) { char *ret = (char *)(ptr+key->offsets[0]); for (int i = 1; (int64_t)key->offsets[i] >= 0; ++i) { - ret = *(char **)(ret+key->offsets[i]); + if (*(char **)ret != NULL) { + ret = (*(char **)ret)+key->offsets[i]; + } else { + return NULL; + } } return (void *)ret; } |