From 338577bb3aa99e62dfe694146eb986f2cc99d502 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 29 Feb 2024 10:12:13 -0800 Subject: [PATCH] ap: check that the last band_freq_attrs was set Static analysis complains that 'last' could be NULL which is true. This really could only happen if every frequency was disabled which likely is impossible but in any case, check before dereferencing the pointer. --- src/ap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ap.c b/src/ap.c index bce389d3..ee3c4dca 100644 --- a/src/ap.c +++ b/src/ap.c @@ -1247,8 +1247,10 @@ static size_t ap_build_country_ie(struct ap_state *ap, uint8_t *out_buf, } /* finish final group */ - *pos++ = nchans; - *pos++ = last->tx_power; + if (last) { + *pos++ = nchans; + *pos++ = last->tx_power; + } len = pos - out_buf - 2;