libsysprof: Avoid a use-after-free in raxRemove

As we are freeing the child, make sure to set it to NULL so that we are not
trying to remove it again.
This commit is contained in:
Corentin Noël
2023-01-18 17:26:20 +01:00
parent 2df6bd6fe0
commit bb83598b12

View File

@ -1052,6 +1052,7 @@ int raxRemove(rax *rax, unsigned char *s, size_t len, void **old) {
debugf("Freeing child %p [%.*s] key:%d\n", (void*)child,
(int)child->size, (char*)child->data, child->iskey);
rax_free(child);
child = NULL;
rax->numnodes--;
h = raxStackPop(&ts);
/* If this node has more then one child, or actually holds