mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
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.
This commit is contained in:
parent
56cc12509c
commit
a7394e1b72
@ -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))
|
if (!hpack_dht_make_room(dht, name.len + value.len))
|
||||||
return 0;
|
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
|
/* Now there is enough room in the table, that's guaranteed by the
|
||||||
* protocol, but not necessarily where we need it.
|
* protocol, but not necessarily where we need it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
used = dht->used;
|
||||||
if (!used) {
|
if (!used) {
|
||||||
/* easy, the table was empty */
|
/* easy, the table was empty */
|
||||||
dht->front = dht->head = 0;
|
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 */
|
/* compute the new head, used and wrap position */
|
||||||
|
prev = head = dht->head;
|
||||||
|
wrap = dht->wrap;
|
||||||
|
tail = hpack_dht_get_tail(dht);
|
||||||
|
|
||||||
used++;
|
used++;
|
||||||
head++;
|
head++;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user