1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-20 05:16:09 +02:00

Merge branch 'sb/plug-leak-in-make-cache-entry' into maint

"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
This commit is contained in:
Junio C Hamano 2015-03-05 13:13:13 -08:00
commit 1e299f5286

View File

@ -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);
@ -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)