]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] counters: fix segfault on missing counters for a listener
authorWilly Tarreau <w@1wt.eu>
Sun, 4 Oct 2009 22:45:38 +0000 (00:45 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 4 Oct 2009 22:45:38 +0000 (00:45 +0200)
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.

src/dumpstats.c

index 1317cc080d2941c85c8db09231ada73b30c5c60c..f59bf9071b2c86956df6ae7a345bba18a4b7f7f0 100644 (file)
@@ -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;