[patch] git: fix memory leak #3 in update-cache.c
- From
- Ingo Molnar <mingo@elte.hu>
- Date
- Apr 14, 2005, 13:31 UTC
- Message-ID
- <20050414133134.GB21543@elte.hu>
- In-Reply-To
- <20050414130309.GA18703@elte.hu>
the patch below fixes a third memory leak in update-cache.c. (the mmap-ed file needs to be unmapped too) Ontop of the previous update-cache.c patches.
Ingo
Signed-off-by: Ingo Molnar <mingo@elte.hu>
--- update-cache.c.orig +++ update-cache.c
@@ -32,6 +32,8 @@ static int index_fd(const char *path, in if (!out || (int)(long)in == -1) { free(out); free(metadata); + if ((int)(long)in != -1 && size) + munmap(in, size); return -1; } @@ -66,6 +68,8 @@ static int index_fd(const char *path, in free(out); free(metadata); + if (size) + munmap(in, size); return ret; }