Open
Description
Hi Daniel, thank you so much for sharing your code with the community.
While experimenting with the hat-trie, I hit an exception in ahtable_iter_key() - when the "i" iterator is NULL:
const char* ahtable_iter_key(ahtable_iter_t* i, size_t* len)
.
I do not understand the code enough to suggest a proper fix, I just "patched" it as follows:
- Add a null check upon the entry into ahtable_iter_key():
const char* ahtable_iter_key(ahtable_iter_t* i, size_t* len)
{
if (i == NULL) return NULL; //add this null check
- Add a null check in hattrie_iter_prefix_satisfied():
if (i->level + size < i->prefixsize) {
// early exit, child key is too short to match prefix
return false;
}
else if (key == NULL) { //add this null check
return false;
} else {
return (memcmp(key, i->prefix + i->level, i->prefixsize - i->level) == 0);
}
This problem only occurs under specific conditions - if necessary, I can provide the input data to replicate the exception.
Kind regards, --Raj
Metadata
Metadata
Assignees
Labels
No labels