Commit dfe59969 authored by Rusty Russell's avatar Rusty Russell

tal: tal_parent(NULL) should be NULL.

Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 6c2ae376
......@@ -638,7 +638,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;
......
......@@ -159,7 +159,7 @@ tal_t *tal_next(const tal_t *root, const tal_t *prev);
* tal_parent - get the parent of a tal object.
* @ctx: The tal allocated object.
*
* Returns the parent, which may be NULL.
* Returns the parent, which may be NULL. Returns NULL if @ctx is NULL.
*/
tal_t *tal_parent(const tal_t *ctx);
......
......@@ -7,10 +7,12 @@ int main(void)
char *parent, *c[4], *p;
int i, j;
plan_tests(10);
plan_tests(12);
parent = tal(NULL, char);
ok1(parent);
ok1(tal_parent(parent) == NULL);
ok1(tal_parent(NULL) == NULL);
for (i = 0; i < 4; i++)
c[i] = tal(parent, char);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment