[patch] git: fix memory leaks in read-cache.c
- From
- Ingo Molnar <mingo@elte.hu>
- Date
- Apr 14, 2005, 12:32 UTC
- Message-ID
- <20050414123258.GA15148@elte.hu>
- In-Reply-To
- <20050414120834.GA14290@elte.hu>
this patch fixes a common and a rare memory leak in read-cache.c.
Ingo
Signed-off-by: Ingo Molnar <mingo@elte.hu>
--- read-cache.c.orig +++ read-cache.c
@@ -226,8 +226,11 @@ int write_sha1_file(char *buf, unsigned SHA1_Update(&c, compressed, size); SHA1_Final(sha1, &c); - if (write_sha1_buffer(sha1, compressed, size) < 0) + if (write_sha1_buffer(sha1, compressed, size) < 0) { + free(compressed); return -1; + } + free(compressed); if (returnsha1) memcpy(returnsha1, sha1, 20); return 0;