summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2022-08-06 12:19:45 -0300
committermrb0nk500 <b0nk@b0nk.xyz>2022-08-06 12:19:45 -0300
commit19ee637cefbdc197c0d249b146f263116812db53 (patch)
tree1f3c7b38ca13eae4bd341341b7d0fb307c96399b
parent83b32144799ac58c845120ef901571869a3b3bc9 (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.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/keyword.c b/keyword.c
index 385f526..3a87c13 100644
--- a/keyword.c
+++ b/keyword.c
@@ -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;
}