diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-05-26 17:53:29 +0400 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-05-26 17:53:29 +0400 |
commit | 1344d20ec08e4fc1b6e4dd08fa7dda07f7b6c9bc (patch) | |
tree | 8fd44806b6aa5d601ebd0bc36fdebcd510221f74 /json_script.c | |
parent | 4436338588cb317b5799d3aa3107d2cb0b6192cc (diff) |
json_script: fix a segfault in the file free handler
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'json_script.c')
-rw-r--r-- | json_script.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/json_script.c b/json_script.c index 9d5e9d2..0ec7b38 100644 --- a/json_script.c +++ b/json_script.c @@ -582,12 +582,18 @@ void json_script_run(struct json_script_ctx *ctx, const char *name, json_script_run_file(ctx, file, vars); } -static void __json_script_file_free(struct json_script_ctx *ctx, struct json_script_file *f) +static void __json_script_file_free(struct json_script_file *f) { struct json_script_file *next; - for (next = f->next; f; f = next, next = f->next) - free(f); + if (!f) + return; + + next = f->next; + free(f); + + if (next) + return __json_script_file_free(next); } void @@ -596,7 +602,7 @@ json_script_free(struct json_script_ctx *ctx) struct json_script_file *f, *next; avl_remove_all_elements(&ctx->files, f, avl, next) - __json_script_file_free(ctx, f); + __json_script_file_free(f); blob_buf_free(&ctx->buf); } |