tal/str: make tal_count() work for strsplit.
[ccan] / ccan / tal / str / str.c
index 09c45447fb6e3e3fa53882f4e4d829cab001aa0b..7d5b103a66cffd848fd6a8371fc1bce5f7c25eca 100644 (file)
@@ -49,6 +49,11 @@ char **strsplit(const tal_t *ctx,
                        goto fail;
        }
        parts[num] = NULL;
+
+       /* Ensure that tal_count() is correct. */
+       if (unlikely(!tal_resize(&parts, num+1)))
+               goto fail;
+
        if (taken(delims))
                tal_free(delims);
        return parts;