vcc.c: Fix a memory leak in recv_afs_result().
authorAndre Noll <maan@systemlinux.org>
Thu, 17 Jan 2008 20:50:20 +0000 (21:50 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 17 Jan 2008 20:50:20 +0000 (21:50 +0100)
This function contained a code path that allocated
the buffer for the chunk table and then returned an error
(due to a failing fstat()) without freeing the chunk table
buffer.

vss.c

diff --git a/vss.c b/vss.c
index 89e06c92beb5b934b567cc48b93a91081d433931..8ba17fc34e4b2e0f3c77452f0ec233ae270e2e22 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -383,6 +383,7 @@ static void recv_afs_result(void)
        struct stat statbuf;
        struct timeval now;
 
+       mmd->afd.afhi.chunk_table = NULL;
        ret = recv_afs_msg(&passed_fd, &afs_code, &afs_data);
        if (ret < 0)
                goto err;
@@ -419,6 +420,7 @@ static void recv_afs_result(void)
        tv_add(&now, &announce_tv, &data_send_barrier);
        return;
 err:
+       free(mmd->afd.afhi.chunk_table);
        if (passed_fd >= 0)
                close(passed_fd);
        PARA_ERROR_LOG("%s\n", para_strerror(-ret));