[nft PATCH] segtree: Fix for variable-sized object may not be initialized

Phil Sutter
2026-03-19T13:32:20Z

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.

Fixes: e8b17865833b8 ("segtree: Fix range aggregation on Big Endian")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
src/segtree.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/segtree.c b/src/segtree.c
index bfea2f64ed812..a12820bcf1ece 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -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] = '*';

--
2.51.0