diff options
author | Ron Yorston <rmy@pobox.com> | 2024-01-19 15:41:17 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2024-03-02 17:03:37 +0100 |
commit | e1a68741067167dc4837e0a26d3d5c318a631fc7 (patch) | |
tree | 06fa438bd54e18aee5e7446c0529455f4b9e8b08 | |
parent | 01f2b5976d03fb50229d28297cf5ebd8be533203 (diff) | |
download | busybox-w32-e1a68741067167dc4837e0a26d3d5c318a631fc7.tar.gz busybox-w32-e1a68741067167dc4837e0a26d3d5c318a631fc7.tar.bz2 busybox-w32-e1a68741067167dc4837e0a26d3d5c318a631fc7.zip |
awk: fix segfault when compiled by clang
A 32-bit build of BusyBox using clang segfaulted in the test
"awk assign while assign". Specifically, on line 7 of the test
input where the adjustment of the L.v pointer when the Fields
array was reallocated
L.v += Fields - old_Fields_ptr;
was out by 4 bytes.
Rearrange to code so both gcc and clang generate code that works.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r-- | editors/awk.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/editors/awk.c b/editors/awk.c index aa485c782..0981c6735 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -3006,7 +3006,7 @@ static var *evaluate(node *op, var *res) | |||
3006 | if (old_Fields_ptr) { | 3006 | if (old_Fields_ptr) { |
3007 | //if (old_Fields_ptr != Fields) | 3007 | //if (old_Fields_ptr != Fields) |
3008 | // debug_printf_eval("L.v moved\n"); | 3008 | // debug_printf_eval("L.v moved\n"); |
3009 | L.v += Fields - old_Fields_ptr; | 3009 | L.v = Fields + (L.v - old_Fields_ptr); |
3010 | } | 3010 | } |
3011 | if (opinfo & OF_STR2) { | 3011 | if (opinfo & OF_STR2) { |
3012 | R.s = getvar_s(R.v); | 3012 | R.s = getvar_s(R.v); |