diff options
author | Brian Foley <bpfoley@google.com> | 2019-09-05 10:50:13 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-10-21 16:54:40 +0200 |
commit | 50ba92128b0a6472a3a85efaaa8ce3bfbda1bce5 (patch) | |
tree | 23c1ee796fac16978671f29dfb0e12f3039c61e6 /miscutils | |
parent | 4699b932446f809d747d97f8e24b5d48608f7276 (diff) | |
download | busybox-w32-50ba92128b0a6472a3a85efaaa8ce3bfbda1bce5.tar.gz busybox-w32-50ba92128b0a6472a3a85efaaa8ce3bfbda1bce5.tar.bz2 busybox-w32-50ba92128b0a6472a3a85efaaa8ce3bfbda1bce5.zip |
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.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 9a9880706..44c70cac3 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -4973,7 +4973,9 @@ static void dc_parse_string(void) | |||
4973 | xc_parse_pushInst_and_Index(XC_INST_STR, len); | 4973 | xc_parse_pushInst_and_Index(XC_INST_STR, len); |
4974 | bc_vec_push(&G.prog.strs, &str); | 4974 | bc_vec_push(&G.prog.strs, &str); |
4975 | 4975 | ||
4976 | // Explanation needed here | 4976 | // Add an empty function so that if zdc_program_execStr ever needs to |
4977 | // parse the string into code (from the 'x' command) there's somewhere | ||
4978 | // to store the bytecode. | ||
4977 | xc_program_add_fn(); | 4979 | xc_program_add_fn(); |
4978 | p->func = xc_program_func(p->fidx); | 4980 | p->func = xc_program_func(p->fidx); |
4979 | 4981 | ||
@@ -6398,7 +6400,11 @@ static BC_STATUS zdc_program_asciify(void) | |||
6398 | str = xzalloc(2); | 6400 | str = xzalloc(2); |
6399 | str[0] = c; | 6401 | str[0] = c; |
6400 | //str[1] = '\0'; - already is | 6402 | //str[1] = '\0'; - already is |
6401 | bc_vec_push(&G.prog.strs, &str); | 6403 | idx = bc_vec_push(&G.prog.strs, &str); |
6404 | // Add an empty function so that if zdc_program_execStr ever needs to | ||
6405 | // parse the string into code (from the 'x' command) there's somewhere | ||
6406 | // to store the bytecode. | ||
6407 | xc_program_add_fn(); | ||
6402 | dup: | 6408 | dup: |
6403 | res.t = XC_RESULT_STR; | 6409 | res.t = XC_RESULT_STR; |
6404 | res.d.id.idx = idx; | 6410 | res.d.id.idx = idx; |