summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2023-01-09 04:39:48 +0100
committerGravatar Nikias Bassen2023-01-09 04:39:48 +0100
commit491a3acc1015951042c95c389a10634e331818c4 (patch)
tree8898273d267d4821735765f3481ca6f6ab6bf3d9
parentb2b9943fc0456d8184d29d2e7f95de2609f907f6 (diff)
downloadlibplist-491a3acc1015951042c95c389a10634e331818c4.tar.gz
libplist-491a3acc1015951042c95c389a10634e331818c4.tar.bz2
oplist: Plug memory leaks occurring when parsing fails
-rw-r--r--src/oplist.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/oplist.c b/src/oplist.c
index fa6977a..b3b782f 100644
--- a/src/oplist.c
+++ b/src/oplist.c
@@ -677,9 +677,13 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist)
ctx->pos++;
}
if (ctx->err) {
+ byte_array_free(bytes);
+ plist_free_data(data);
goto err_out;
}
if (*ctx->pos != '>') {
+ byte_array_free(bytes);
+ plist_free_data(data);
PLIST_OSTEP_ERR("Missing terminating '>' at offset %ld\n", ctx->pos - ctx->start);
ctx->err++;
goto err_out;
@@ -707,6 +711,7 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist)
ctx->pos++;
}
if (*ctx->pos != c) {
+ plist_free_data(data);
PLIST_OSTEP_ERR("Missing closing quote (%c) at offset %ld\n", c, ctx->pos - ctx->start);
ctx->err++;
goto err_out;
@@ -807,6 +812,7 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist)
parse_skip_ws(ctx);
break;
} else {
+ plist_free_data(data);
PLIST_OSTEP_ERR("Unexpected character when parsing unquoted string at offset %ld\n", ctx->pos - ctx->start);
ctx->err++;
break;
@@ -817,6 +823,7 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist)
err_out:
if (ctx->err) {
+ plist_free(subnode);
plist_free(*plist);
*plist = NULL;
return PLIST_ERR_PARSE;