tal: make tal_len/tal_count(NULL) return 0.
[ccan] / ccan / tal / tal.c
index 2a2eca77c04f5bbd37cc35e4ee4c4507e17ec33a..555dd1333d8f7be28ae837b4a4f0d1cba5686d07 100644 (file)
@@ -654,6 +654,9 @@ size_t tal_len(const tal_t *ptr)
 {
        struct length *l;
 
+       if (!ptr)
+               return 0;
+
        l = find_property(debug_tal(to_tal_hdr(ptr)), LENGTH);
        if (!l)
                return 0;