summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2023-01-11 03:49:36 +0100
committerGravatar Nikias Bassen2023-01-11 03:49:36 +0100
commit12a2bc0578d148dcd03d26a3a1b33bccaecfdf33 (patch)
tree1b8889599af3b7caa66799734509a38d725ec169 /src
parent643e0a3bcc6e2738d9cca28dc00e6dc9d6a04b1d (diff)
downloadlibplist-12a2bc0578d148dcd03d26a3a1b33bccaecfdf33.tar.gz
libplist-12a2bc0578d148dcd03d26a3a1b33bccaecfdf33.tar.bz2
oplist: Plug some more memory leaks occuring when parsing fails
Diffstat (limited to 'src')
-rw-r--r--src/oplist.c9
1 files changed, 5 insertions, 4 deletions
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;
}