]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Fix memory leak at exit.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 22 Mar 2022 20:05:19 +0000 (21:05 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 27 Mar 2022 18:12:18 +0000 (20:12 +0200)
If command_post_select() returns failure because of a notification we
leak the array of listening fds. No big deal, but worth to fix anyway.

server.c

index 09087f7a72396bf01e51782dbebc1b9d1a82eb7c..d51e4e0bfe5b33c341ff744eda4f9380bd666844 100644 (file)
--- a/server.c
+++ b/server.c
@@ -432,15 +432,16 @@ static int command_post_select(struct sched *s, void *context)
 
        ret = task_get_notification(sct->task);
        if (ret < 0)
-               return ret;
+               goto fail;
        for (n = 0; n < sct->num_listen_fds; n++) {
                ret = command_task_accept(n, s, sct);
-               if (ret < 0) {
-                       free(sct->listen_fds);
-                       return ret;
-               }
+               if (ret < 0)
+                       goto fail;
        }
        return 0;
+fail:
+       free(sct->listen_fds);
+       return ret;
 }
 
 static void init_server_command_task(struct server_command_task *sct,