summaryrefslogtreecommitdiffstats
path: root/src
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 /src
parentb2b9943fc0456d8184d29d2e7f95de2609f907f6 (diff)
downloadlibplist-491a3acc1015951042c95c389a10634e331818c4.tar.gz
libplist-491a3acc1015951042c95c389a10634e331818c4.tar.bz2
oplist: Plug memory leaks occurring when parsing fails
Diffstat (limited to 'src')
-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)
677 ctx->pos++; 677 ctx->pos++;
678 } 678 }
679 if (ctx->err) { 679 if (ctx->err) {
680 byte_array_free(bytes);
681 plist_free_data(data);
680 goto err_out; 682 goto err_out;
681 } 683 }
682 if (*ctx->pos != '>') { 684 if (*ctx->pos != '>') {
685 byte_array_free(bytes);
686 plist_free_data(data);
683 PLIST_OSTEP_ERR("Missing terminating '>' at offset %ld\n", ctx->pos - ctx->start); 687 PLIST_OSTEP_ERR("Missing terminating '>' at offset %ld\n", ctx->pos - ctx->start);
684 ctx->err++; 688 ctx->err++;
685 goto err_out; 689 goto err_out;
@@ -707,6 +711,7 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist)
707 ctx->pos++; 711 ctx->pos++;
708 } 712 }
709 if (*ctx->pos != c) { 713 if (*ctx->pos != c) {
714 plist_free_data(data);
710 PLIST_OSTEP_ERR("Missing closing quote (%c) at offset %ld\n", c, ctx->pos - ctx->start); 715 PLIST_OSTEP_ERR("Missing closing quote (%c) at offset %ld\n", c, ctx->pos - ctx->start);
711 ctx->err++; 716 ctx->err++;
712 goto err_out; 717 goto err_out;
@@ -807,6 +812,7 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist)
807 parse_skip_ws(ctx); 812 parse_skip_ws(ctx);
808 break; 813 break;
809 } else { 814 } else {
815 plist_free_data(data);
810 PLIST_OSTEP_ERR("Unexpected character when parsing unquoted string at offset %ld\n", ctx->pos - ctx->start); 816 PLIST_OSTEP_ERR("Unexpected character when parsing unquoted string at offset %ld\n", ctx->pos - ctx->start);
811 ctx->err++; 817 ctx->err++;
812 break; 818 break;
@@ -817,6 +823,7 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist)
817 823
818err_out: 824err_out:
819 if (ctx->err) { 825 if (ctx->err) {
826 plist_free(subnode);
820 plist_free(*plist); 827 plist_free(*plist);
821 *plist = NULL; 828 *plist = NULL;
822 return PLIST_ERR_PARSE; 829 return PLIST_ERR_PARSE;