From 59d52d5802afe2ffad74f83d8084bac5085b24e3 Mon Sep 17 00:00:00 2001 From: Arne Goedeke <el@laramies.com> Date: Tue, 13 Apr 2021 08:40:14 +0200 Subject: [PATCH] decode_value: Do not leak arrays on error This commit fixes a situation in which, when an error happens while decoding the content of a multiset, a temporary array would leak. Thanks to Joshua Rogers <jrogers@opera.com> for the report. --- src/encode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/encode.c b/src/encode.c index 72e9b1a7e4..fd124983a0 100644 --- a/src/encode.c +++ b/src/encode.c @@ -2792,7 +2792,7 @@ static void decode_value2(struct decode_data *data) SETUP_DECODE_MEMOBJ (T_MULTISET, multiset, m, allocate_multiset (0, 0, NULL), ;); /* FIXME: This array could be avoided by building the multiset directly. */ - a = low_allocate_array (num, 0); + push_array(a = low_allocate_array (num, 0)); types = 0; for(e=0;e<num;e++) @@ -2804,7 +2804,7 @@ static void decode_value2(struct decode_data *data) a->type_field = types; { struct multiset *l = mkmultiset (a); - free_array (a); + pop_stack(); /* This special case is handled efficiently by merge_multisets. */ merge_multisets (m, l, PIKE_MERGE_DESTR_A | PIKE_ARRAY_OP_ADD); free_multiset (l); -- GitLab