]> git.tue.mpg.de Git - paraslash.git/commitdiff
Fix some memory leaks.
authorAndre Noll <maan@systemlinux.org>
Sun, 22 Mar 2009 12:58:28 +0000 (13:58 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 22 Mar 2009 12:58:28 +0000 (13:58 +0100)
In fact, there was only one "real" leak: An empty info string (100
bytes) could leak on file change.

command.c
server.c
vss.c

index b59fae7af154d5545999ae6b79757c06b7c118ee..d08a71818cfb437c5cd6c02a13d6a7c2f3e56893 100644 (file)
--- a/command.c
+++ b/command.c
@@ -787,12 +787,14 @@ __noreturn void handle_connect(int fd, const char *peername)
        /* valid command and sufficient perms */
        alarm(0);
        argc = split_args(command, &argv, "\n");
-       mutex_lock(mmd_mutex);
-       mmd->num_commands++;
-       mutex_unlock(mmd_mutex);
        PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", cmd->name, u->name,
                        peername);
        ret = cmd->handler(fd, argc, argv);
+       mutex_lock(mmd_mutex);
+       mmd->num_commands++;
+       free(mmd->afd.afhi.info_string);
+       free(mmd->afd.afhi.chunk_table);
+       mutex_unlock(mmd_mutex);
        if (ret >= 0)
                goto out;
 err_out:
index 4415cdcdb1ba425d2aff8d91c66b4b8ae7619632..1e4caf08c90d0e04233a987f6e520e19850c20c5 100644 (file)
--- a/server.c
+++ b/server.c
@@ -300,6 +300,9 @@ static void signal_post_select(struct sched *s, struct task *t)
                PARA_EMERG_LOG("terminating on signal %d\n", st->signum);
 genocide:
                kill(0, SIGTERM);
+               free(mmd->afd.afhi.chunk_table);
+               free(mmd->afd.afhi.info_string);
+               close_listed_fds();
                mutex_destroy(mmd_mutex);
                shm_detach(mmd);
                exit(EXIT_FAILURE);
diff --git a/vss.c b/vss.c
index 066a8851bca7633f04dfb139d4c15ec19f5cdfa1..10780cbffe1a9026e1729423c0e98bfe1dddeabd 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -740,7 +740,6 @@ static void recv_afs_result(struct vss_task *vsst)
        struct stat statbuf;
 
        vsst->afsss = AFS_SOCKET_READY;
-       mmd->afd.afhi.chunk_table = NULL;
        ret = recv_afs_msg(vsst->afs_socket, &passed_fd, &afs_code, &afs_data);
        if (ret < 0)
                goto err;
@@ -752,6 +751,7 @@ static void recv_afs_result(struct vss_task *vsst)
        if (passed_fd < 0)
                goto err;
        shmid = afs_data;
+       free(mmd->afd.afhi.info_string);
        ret = load_afd(shmid, &mmd->afd);
        if (ret < 0)
                goto err;