diff options
author | Ron Yorston <rmy@pobox.com> | 2024-01-19 15:19:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-01-19 15:19:49 +0000 |
commit | 042520e46621e434c9bd2da6b100b32ccdee55a5 (patch) | |
tree | b447f439a2fe16ad1e2f7517976d0fae39abfdea | |
parent | ea8742bc1657cd0aae32ac555560c8228795488f (diff) | |
download | busybox-w32-042520e46621e434c9bd2da6b100b32ccdee55a5.tar.gz busybox-w32-042520e46621e434c9bd2da6b100b32ccdee55a5.tar.bz2 busybox-w32-042520e46621e434c9bd2da6b100b32ccdee55a5.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.
This patch has been submitted upstream. Until it's accepted there
the new code is only used in builds for Windows.
-rw-r--r-- | editors/awk.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/editors/awk.c b/editors/awk.c index 3ca0c5fce..8d88fce76 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -3029,7 +3029,11 @@ static var *evaluate(node *op, var *res) | |||
3029 | if (old_Fields_ptr) { | 3029 | if (old_Fields_ptr) { |
3030 | //if (old_Fields_ptr != Fields) | 3030 | //if (old_Fields_ptr != Fields) |
3031 | // debug_printf_eval("L.v moved\n"); | 3031 | // debug_printf_eval("L.v moved\n"); |
3032 | #if !ENABLE_PLATFORM_MINGW32 | ||
3032 | L.v += Fields - old_Fields_ptr; | 3033 | L.v += Fields - old_Fields_ptr; |
3034 | #else | ||
3035 | L.v = Fields + (L.v - old_Fields_ptr); | ||
3036 | #endif | ||
3033 | } | 3037 | } |
3034 | if (opinfo & OF_STR2) { | 3038 | if (opinfo & OF_STR2) { |
3035 | R.s = getvar_s(R.v); | 3039 | R.s = getvar_s(R.v); |