From 12a2bc0578d148dcd03d26a3a1b33bccaecfdf33 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 11 Jan 2023 03:49:36 +0100 Subject: oplist: Plug some more memory leaks occuring when parsing fails --- src/oplist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/oplist.c b/src/oplist.c index deb54de..168c921 100644 --- a/src/oplist.c +++ b/src/oplist.c @@ -560,11 +560,9 @@ static void parse_dict_data(parse_ctx ctx, plist_t dict) val = NULL; ctx->err = node_from_openstep(ctx, &val); if (ctx->err != 0) { - plist_free(key); break; } if (!val) { - plist_free(key); PLIST_OSTEP_ERR("Missing value for dictionary item at offset %ld\n", ctx->pos - ctx->start); ctx->err++; break; @@ -576,8 +574,6 @@ static void parse_dict_data(parse_ctx ctx, plist_t dict) break; } if (*ctx->pos != ';') { - plist_free(val); - plist_free(key); PLIST_OSTEP_ERR("Missing terminating ';' while parsing dictionary item at offset %ld\n", ctx->pos - ctx->start); ctx->err++; break; @@ -585,10 +581,13 @@ static void parse_dict_data(parse_ctx ctx, plist_t dict) plist_dict_set_item(dict, plist_get_string_ptr(key, NULL), val); plist_free(key); + key = NULL; val = NULL; ctx->pos++; } + plist_free(key); + plist_free(val); } static int node_from_openstep(parse_ctx ctx, plist_t *plist) @@ -654,6 +653,8 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist) } ctx->pos++; } + plist_free(tmp); + tmp = NULL; if (ctx->err) { goto err_out; } -- cgit v1.1-32-gdbae