while starting a valid config with check option (`-c`)
trying to fix the following segfault:

  Program received signal SIGSEGV, Segmentation fault.
  0x00005555556b81b9 in deinit () at src/haproxy.c:2455
  2455                    if (!fdtab[cur_fd].owner)
  #0  0x00005555556b81b9 in deinit () at src/haproxy.c:2455
  #1  0x00005555556b98d8 in deinit_and_exit (status=status@entry=0) at 
src/haproxy.c:2814
  #2  0x00005555556ba77d in init (argc=<optimized out>, argc@entry=5, 
argv=<optimized out>, argv@entry=0x7fffffffe578) at src/haproxy.c:2028
  #3  0x00005555555963e6 in main (argc=5, argv=0x7fffffffe578) at 
src/haproxy.c:3069

no backport needed

Signed-off-by: William Dauchy <[email protected]>
---
 src/haproxy.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/haproxy.c b/src/haproxy.c
index 3924df1d5..610051df6 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2451,15 +2451,17 @@ void deinit(void)
         */
        protocol_unbind_all();
 
-       for (cur_fd = 0; cur_fd < global.maxsock; cur_fd++) {
-               if (!fdtab[cur_fd].owner)
-                       continue;
+       if (fdtab) {
+               for (cur_fd = 0; cur_fd < global.maxsock; cur_fd++) {
+                       if (!fdtab[cur_fd].owner)
+                               continue;
 
-               if (fdtab[cur_fd].iocb == listener_accept) {
-                       struct listener *l = fdtab[cur_fd].owner;
+                       if (fdtab[cur_fd].iocb == listener_accept) {
+                               struct listener *l = fdtab[cur_fd].owner;
 
-                       BUG_ON(l->state != LI_INIT);
-                       unbind_listener(l);
+                               BUG_ON(l->state != LI_INIT);
+                               unbind_listener(l);
+                       }
                }
        }
 
-- 
2.28.0


Reply via email to