summaryrefslogtreecommitdiffstats
path: root/zix/trie.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-13 17:25:55 +0200
committerDavid Robillard <d@drobilla.net>2020-08-13 17:25:55 +0200
commit59d5056a65062ff2b46bcf477651e71f5d4984e0 (patch)
tree3ef5c355b26546355deb2f1b5ec8a713692b898c /zix/trie.c
parent8e31bb8064f5e2b2e0bfb8e9e6e5f85091e3a8bc (diff)
downloadzix-59d5056a65062ff2b46bcf477651e71f5d4984e0.tar.gz
zix-59d5056a65062ff2b46bcf477651e71f5d4984e0.tar.bz2
zix-59d5056a65062ff2b46bcf477651e71f5d4984e0.zip
Fix potential null pointer dereferences
Diffstat (limited to 'zix/trie.c')
-rw-r--r--zix/trie.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/zix/trie.c b/zix/trie.c
index 5083f3b..29f31d1 100644
--- a/zix/trie.c
+++ b/zix/trie.c
@@ -215,7 +215,11 @@ trie_insert_tail(ZixTrieNode** n_ptr,
while (first[0]) {
assert(zix_trie_node_check(*n_ptr));
- c = realloc_node(NULL, 1);
+ c = realloc_node(NULL, 1);
+ if (!c) {
+ return NULL;
+ }
+
c->str = NULL;
c->num_children = 0;
@@ -225,6 +229,11 @@ trie_insert_tail(ZixTrieNode** n_ptr,
++first;
}
+
+ if (!c) {
+ return NULL;
+ }
+
c->num_children = 0;
c->str = str;
assert(zix_trie_node_check(c));