this patch cleans up add_file_to_cache() to free up all memory it
allocates. This has no significance right now as the only user of
add_file_to_cache() die()s immediately in the 'leak' paths - but if the
function is ever used without dying then this uncleanliness could lead
to a memory leak.
Ingo
Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
--- update-cache.c.orig
+++ update-cache.c
@@ -120,10 +120,17 @@ static int add_file_to_cache(char *path)
ce->st_size = st.st_size;
ce->namelen = namelen;
- if (index_fd(path, namelen, ce, fd, &st) < 0)
+ if (index_fd(path, namelen, ce, fd, &st) < 0) {
+ free(ce);
return -1;
+ }
- return add_cache_entry(ce, allow_add);
+ if (add_cache_entry(ce, allow_add)) {
+ free(ce);
+ return -1;
+ }
+
+ return 0;
}
static int match_data(int fd, void *buffer, unsigned long size)
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html