Skip to content

Commit 59efba6

Browse files
jrngitster
authored andcommitted
core: Stop leaking ondisk_cache_entrys
Noticed with valgrind. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 64fdc08 commit 59efba6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

read-cache.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,7 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce)
15161516
int size = ondisk_ce_size(ce);
15171517
struct ondisk_cache_entry *ondisk = xcalloc(1, size);
15181518
char *name;
1519+
int result;
15191520

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

1542-
return ce_write(c, fd, ondisk, size);
1543+
result = ce_write(c, fd, ondisk, size);
1544+
free(ondisk);
1545+
return result;
15431546
}
15441547

15451548
int write_index(struct index_state *istate, int newfd)

0 commit comments

Comments
 (0)