segtree: Fix for variable-sized object may not be initialized
Phil Sutter
reviewerPATCH 1/1 segtree: Fix for variable-sized object may not be initialized
Seen with gcc-11.5.0 on an aarch64 machine, build failed. Looking at the code, r1len (or r1->len, actually) really seems variable. So use memset() and fix build for that older compiler version at least.
--- src/segtree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
src/segtree.c +2 -1
@@ -426,8 +426,9 @@ void concat_range_aggregate(struct expr *set) string_type) {unsigned int r1len =div_round_up (r1->len,BITS_PER_BYTE );unsigned int str_len = prefix_len /BITS_PER_BYTE ; -char data[r1len +1 ] = {}; +char data[r1len +1 ]; +memset (data,0 , r1len +1 );mpz_export_data (data, r1->value,BYTEORDER_HOST_ENDIAN , r1len); data[str_len] ='*' ;
Signature · 1 line
2.51.0
Quoted 3 lines · Phil Sutter
Seen with gcc-11.5.0 on an aarch64 machine, build failed. Looking at the code, r1len (or
r1->len, actually) really seems variable. So usememset()and fix build for that older compiler version at least.
Thanks for fixing this.
Phil Sutter
reviewerQuoted 8 lines · Florian Westphal
Quoted 3 lines · Phil Sutter
Seen with gcc-11.5.0 on an aarch64 machine, build failed. Looking at the code, r1len (or
r1->len, actually) really seems variable. So usememset()and fix build for that older compiler version at least.Thanks for fixing this.
Acked-by Florian Westphal <[email protected]>
Patch applied, thanks for your review!