]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ncbmbuf: improve itbmap_next() code
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 23 Feb 2026 09:04:45 +0000 (10:04 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 23 Feb 2026 15:28:41 +0000 (16:28 +0100)
itbmap_next() advances an iterator over a ncbmbuf buffer storage. When
reaching the end of the buffer, <b> field is set to NULL, and the caller
is expected to stop working with the iterator.

Complete this part to ensure that itbmap type is fully initialized in
case null iterator value is returned. This is not strictly required
given the above description, but this is better to avoid any possible
future mistake.

This should fix coverity issue from github #3273.

This could be backported up to 2.8.

src/ncbmbuf.c

index 6f66e9cae076d3d63b917821210602490b8c4ab2..222737ea694715750365866889073cc985871016 100644 (file)
@@ -143,6 +143,8 @@ static struct itbmap itbmap_next(const struct ncbmbuf *buf,
        if (off_next == ncbmb_size(buf)) {
                next.b = NULL;
                next.off = off_next;
+               next.mask = 0;
+               next.bits = 0;
        }
        else {
                itbmap_load(&next, prev->off + prev->bits, buf);