X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftal%2Ftal.c;h=474c0ff045c72f3f03c426851dc3e47ed365e4ba;hb=78ba5de2dc4c74f772b9e40cd673476dac6d7a1a;hp=9fed477fe9595bd4e85d5243f1315c602915a830;hpb=6c2ae3766a8cc59bf6903dcd60a559095f7655a4;p=ccan diff --git a/ccan/tal/tal.c b/ccan/tal/tal.c index 9fed477f..474c0ff0 100644 --- a/ccan/tal/tal.c +++ b/ccan/tal/tal.c @@ -455,6 +455,7 @@ static struct tal_hdr *remove_node(struct tal_hdr *t) /* Are we the only one? */ if (prev == t) { + struct prop_hdr *next = (*prop)->next; struct children *c = group->parent_child; /* Is this the group embedded in the child property? */ if (group == &c->group) { @@ -462,9 +463,9 @@ static struct tal_hdr *remove_node(struct tal_hdr *t) } else { /* Empty group, so free it. */ list_del_from(&c->group.list, &group->list.n); - *prop = group->hdr.next; freefn(group); } + *prop = next; return c->parent; } else { /* Move property to next node. */ @@ -638,7 +639,12 @@ tal_t *tal_next(const tal_t *root, const tal_t *prev) tal_t *tal_parent(const tal_t *ctx) { struct group *group; - struct tal_hdr *t = debug_tal(to_tal_hdr(ctx)); + struct tal_hdr *t; + + if (!ctx) + return NULL; + + t = debug_tal(to_tal_hdr(ctx)); while (!(group = find_property(t, GROUP))) t = t->next;