From: Willy Tarreau Date: Tue, 27 Mar 2018 13:06:02 +0000 (+0200) Subject: BUG/MINOR: hpack: fix harmless use of uninitialized value in hpack_dht_insert X-Git-Tag: v1.9-dev1~342 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7394e1b72706abcd5bdda254dfd86877fee400b;p=thirdparty%2Fhaproxy.git BUG/MINOR: hpack: fix harmless use of uninitialized value in hpack_dht_insert A warning is reported here by valgrind on first pass in hpack_dht_insert(). The cause is that the not-yet-initialized dht->head is checked in hpack_dht_get_tail(), though the result is not used, making it have no impact. At the very least it confuses valgrind, and maybe it makes it harder for gcc to optimize the code path. Let's move the variable initialization around to shut it up. Thanks to Olivier for reporting this one. This fix may be backported to 1.8 at least to make valgrind usage less painful. --- diff --git a/src/hpack-tbl.c b/src/hpack-tbl.c index 92601f3f90..02e5a5cfe7 100644 --- a/src/hpack-tbl.c +++ b/src/hpack-tbl.c @@ -261,15 +261,11 @@ int hpack_dht_insert(struct hpack_dht *dht, struct ist name, struct ist value) if (!hpack_dht_make_room(dht, name.len + value.len)) return 0; - used = dht->used; - prev = head = dht->head; - wrap = dht->wrap; - tail = hpack_dht_get_tail(dht); - /* Now there is enough room in the table, that's guaranteed by the * protocol, but not necessarily where we need it. */ + used = dht->used; if (!used) { /* easy, the table was empty */ dht->front = dht->head = 0; @@ -281,6 +277,10 @@ int hpack_dht_insert(struct hpack_dht *dht, struct ist name, struct ist value) } /* compute the new head, used and wrap position */ + prev = head = dht->head; + wrap = dht->wrap; + tail = hpack_dht_get_tail(dht); + used++; head++;