Skip to content
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

art_iter_prefix depth goes over key_len #40

Open
lmcmgig opened this issue Feb 5, 2019 · 0 comments
Open

art_iter_prefix depth goes over key_len #40

lmcmgig opened this issue Feb 5, 2019 · 0 comments

Comments

@lmcmgig
Copy link

lmcmgig commented Feb 5, 2019

With a specific data set, the art_iter_prefix find a full_match and goes deeper of the key_len.

// Bail if the prefix does not match
if (n->partial_len) {
[...]
// if there is a full match, go deeper
depth = depth + n->partial_len;
}
[...]
child = find_child(n, key[depth]); //KABOOUM when key_len is less than the depth

Simply change? :

            // If we've matched the prefix, iterate on this node
            if (prefix_len && ((depth + prefix_len) == key_len)) {
                return recursive_iter(n, cb, data);

            // If mismatch or no match, search is terminated
            } else if(prefix_len < n->partial_len) {
                return 0;
            }

Not 100% sure is the optimal solution.

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