Skip to content

Commit

Permalink
Merge branch 'sb/plug-leak-in-make-cache-entry' into maint
Browse files Browse the repository at this point in the history
"update-index --refresh" used to leak when an entry cannot be
refreshed for whatever reason.

* sb/plug-leak-in-make-cache-entry:
  read-cache.c: free cache entry when refreshing fails
  • Loading branch information
Junio C Hamano committed Mar 5, 2015
2 parents 4e0d620 + bc1c2ca commit 1e299f5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ struct cache_entry *make_cache_entry(unsigned int mode,
unsigned int refresh_options)
{
int size, len;
struct cache_entry *ce;
struct cache_entry *ce, *ret;

if (!verify_path(path)) {
error("Invalid path '%s'", path);
Expand All @@ -742,7 +742,13 @@ struct cache_entry *make_cache_entry(unsigned int mode,
ce->ce_namelen = len;
ce->ce_mode = create_ce_mode(mode);

return refresh_cache_entry(ce, refresh_options);
ret = refresh_cache_entry(ce, refresh_options);
if (!ret) {
free(ce);
return NULL;
} else {
return ret;
}
}

int ce_same_name(const struct cache_entry *a, const struct cache_entry *b)
Expand Down

0 comments on commit 1e299f5

Please sign in to comment.