diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-22 23:16:54 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-22 23:16:54 +0100 |
commit | 124f5f357c43bc8eed77a234636cb171826dd95e (patch) | |
tree | 78b28149943e7d7cdda2615e105e71a62bf8116e | |
parent | Fix errors shown by scan-build. (diff) | |
download | calp-124f5f357c43bc8eed77a234636cb171826dd95e.tar.gz calp-124f5f357c43bc8eed77a234636cb171826dd95e.tar.xz |
Fix GET(TRIE(T)) erroring when target was a neighbour.
Diffstat (limited to '')
-rw-r--r-- | src/trie.inc.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/trie.inc.h b/src/trie.inc.h index ffc8ac8e..64e5239d 100644 --- a/src/trie.inc.h +++ b/src/trie.inc.h @@ -87,16 +87,19 @@ TYPE* GET(TRIE(TYPE)) ( TRIE(TYPE)* trie, char* key ) { char* subkey = key; while (n != NULL) { - if (subkey[1] == '\0') { - /* Wanted node found, - * value can however be NULL */ - return n->value; - } else if (subkey[0] == n->c) { - n = n->child; - subkey++; + if (subkey[0] == n->c) { + if (subkey[1] == '\0') { + /* Wanted node found, + * value can however be NULL */ + return n->value; + } else { + n = n->child; + subkey++; + } } else { n = n->next; } + } /* Position not found */ |