json_script: fix a segfault in the file free handler
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
parent
4436338588
commit
1344d20ec0
1 changed files with 10 additions and 4 deletions
|
@ -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)
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue