]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
vss: Avoid double free on exit.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 20 Sep 2021 18:42:37 +0000 (20:42 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 29 Sep 2021 17:03:37 +0000 (19:03 +0200)
When para_server fails to receive the fd for the next audio file,
the memory pointed to by mmd->afd.afhi.chunk_table is freed but the
pointer is not set to NULL. If the failure was due to server and afs
receiving SIGINT, the subsequent signal handling code might attempt
to free the chunk table again. This double free error is detected by
glibc, which results resulting in messages such as

free(): invalid size
Aborted

Fortunately, this is easy to fix.

vss.c

diff --git a/vss.c b/vss.c
index 101fdb8818b4fe8ca794bda2cd71a385b093df02..4b1bfc78986321d1df9335517dd00a87cda0dd87 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -1001,6 +1001,7 @@ static void recv_afs_result(struct vss_task *vsst, fd_set *rfds)
        return;
 err:
        free(mmd->afd.afhi.chunk_table);
        return;
 err:
        free(mmd->afd.afhi.chunk_table);
+       mmd->afd.afhi.chunk_table = NULL;
        if (passed_fd >= 0)
                close(passed_fd);
        PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        if (passed_fd >= 0)
                close(passed_fd);
        PARA_ERROR_LOG("%s\n", para_strerror(-ret));