summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorBrian Foley2019-09-05 10:50:13 +0200
committerDenys Vlasenko2019-09-05 10:50:13 +0200
commitb64470be177314e8473fae6c32cab51cacb89fa7 (patch)
tree046c39f3f8a4b9c5aa4234df7601e6f2f468e642 /miscutils
parent7454879a1d9e3948a9af21e31e9d59d5ae8b89f2 (diff)
downloadbusybox-b64470be177314e8473fae6c32cab51cacb89fa7.zip
busybox-b64470be177314e8473fae6c32cab51cacb89fa7.tar.gz
dc: Fix segfault when executing strings generated using asciify
function old new delta zxc_vm_process 6884 6891 +7 Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 4a3ae49..016300a 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -4973,7 +4973,9 @@ static void dc_parse_string(void)
xc_parse_pushInst_and_Index(XC_INST_STR, len);
bc_vec_push(&G.prog.strs, &str);
- // Explanation needed here
+ // Add an empty function so that if zdc_program_execStr ever needs to
+ // parse the string into code (from the 'x' command) there's somewhere
+ // to store the bytecode.
xc_program_add_fn();
p->func = xc_program_func(p->fidx);
@@ -6398,7 +6400,11 @@ static BC_STATUS zdc_program_asciify(void)
str = xzalloc(2);
str[0] = c;
//str[1] = '\0'; - already is
- bc_vec_push(&G.prog.strs, &str);
+ idx = bc_vec_push(&G.prog.strs, &str);
+ // Add an empty function so that if zdc_program_execStr ever needs to
+ // parse the string into code (from the 'x' command) there's somewhere
+ // to store the bytecode.
+ xc_program_add_fn();
dup:
res.t = XC_RESULT_STR;
res.d.id.idx = idx;