]> PatchyGit - patchyircd.git/commitdiff
trie_findfirst: fix subtle bug with struct reusal
authorEgor <egor@patchysicp.xyz>
Sun, 22 Oct 2023 21:36:37 +0000 (00:36 +0300)
committerEgor <egor@patchysicp.xyz>
Sun, 22 Oct 2023 21:36:37 +0000 (00:36 +0300)
src/map_trie.c

index e91e082..2f2dc66 100644 (file)
@@ -171,9 +171,9 @@ int map_findfirst(map_find_t *pf, map_t *root) {
                f = *pf = malloc(sizeof(*f));
                if (!f)
                        return -1;
-               f->_len = 0;
        }
        f->_n = *root;
+       f->_len = 0;
        if (f->_n->value) {
                f->key[f->_len] = '\0';
                f->value = f->_n->value;