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
Open
@RajNaiduWTG

Description

@RajNaiduWTG

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0