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;