BUG/MINOR: haproxy: Free srule->expr during deinit
authorTim Duesterhus <tim@bastelstu.be>
Sat, 4 Jul 2020 09:49:44 +0000 (11:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 7 Jul 2020 14:52:35 +0000 (16:52 +0200)
commit826cf0729befe34ef5d247fdb077be197054691e
treeb4a6a4b7b9051adf9de1436aabb0a260334fa698
parent6fb74a1dc3e7aeb1092be05a46bbb75e2638e0aa
BUG/MINOR: haproxy: Free srule->expr during deinit

Given the following example configuration:

    backend foo
     mode http
     use-server %[str(x)] if { always_true }
     server x example.com:80

Running a configuration check with valgrind reports:

    ==19376== 170 (40 direct, 130 indirect) bytes in 1 blocks are definitely lost in loss record 281 of 347
    ==19376==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==19376==    by 0x5091AC: add_sample_to_logformat_list (log.c:511)
    ==19376==    by 0x50A5A6: parse_logformat_string (log.c:671)
    ==19376==    by 0x4957F2: check_config_validity (cfgparse.c:2588)
    ==19376==    by 0x54442D: init (haproxy.c:2129)
    ==19376==    by 0x421E42: main (haproxy.c:3169)

After this patch is applied the leak is gone as expected.

This is a very minor leak that can only be observed if deinit() is called,
shortly before the OS will free all memory of the process anyway. No
backport needed.
src/haproxy.c