8000 Exception thrown on NULL pointer in ahtable_iter_key() · Issue #41 · dcjones/hat-trie · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Exception thrown on NULL pointer in ahtable_iter_key() #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RajNaiduWTG opened this issue Apr 13, 2025 · 0 comments
Open

Exception thrown on NULL pointer in ahtable_iter_key() #41

RajNaiduWTG opened this issue Apr 13, 2025 · 0 comments

Comments

@RajNaiduWTG
Copy link
RajNaiduWTG commented Apr 13, 2025

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:

  1. 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
  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0