From: Willy Tarreau Date: Sun, 4 Oct 2009 22:45:38 +0000 (+0200) Subject: [BUG] counters: fix segfault on missing counters for a listener X-Git-Tag: v1.4-dev4~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba255bc3c889cf8dd31b941ede6f8603ce8f758e;p=thirdparty%2Fhaproxy.git [BUG] counters: fix segfault on missing counters for a listener If a frontend does not set 'option socket-stats', a 'clear counters' on the stats socket could segfault because li->counters is NULL. The correct fix is to check for NULL before as this is a valid situation. --- diff --git a/src/dumpstats.c b/src/dumpstats.c index 1317cc080d..f59bf9071b 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -317,7 +317,8 @@ int stats_sock_parse_request(struct stream_interface *si, char *line) memset(&sv->counters, 0, sizeof(sv->counters)); for (li = px->listen; li; li = li->next) - memset(li->counters, 0, sizeof(*li->counters)); + if (li->counters) + memset(li->counters, 0, sizeof(*li->counters)); } return 1;