Skip to content

art_iter_prefix depth goes over key_len #40

@lmcmgig

Description

@lmcmgig

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.

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