Skip to content

Commit

Permalink
core: Stop leaking ondisk_cache_entrys
Browse files Browse the repository at this point in the history
Noticed with valgrind.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Aug 11, 2010
1 parent 64fdc08 commit 59efba6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,7 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce)
int size = ondisk_ce_size(ce);
struct ondisk_cache_entry *ondisk = xcalloc(1, size);
char *name;
int result;

ondisk->ctime.sec = htonl(ce->ce_ctime.sec);
ondisk->mtime.sec = htonl(ce->ce_mtime.sec);
Expand All @@ -1539,7 +1540,9 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce)
name = ondisk->name;
memcpy(name, ce->name, ce_namelen(ce));

return ce_write(c, fd, ondisk, size);
result = ce_write(c, fd, ondisk, size);
free(ondisk);
return result;
}

int write_index(struct index_state *istate, int newfd)
Expand Down

0 comments on commit 59efba6

Please sign in to comment.