diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-03-05 13:13:13 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-03-05 13:13:14 -0800 |
commit | 1e299f52869f3bf40e1c22721cd23bb6b4b43500 (patch) | |
tree | a4e0690e9e98db95247e2878129a6cc75ba05675 /read-cache.c | |
parent | 4e0d6207e58fe19be9343395c979bcb92d09b4a9 (diff) | |
parent | bc1c2caa7397e7e462f0cc7631a40f6e7cd480ab (diff) | |
download | git-1e299f52869f3bf40e1c22721cd23bb6b4b43500.tar.gz git-1e299f52869f3bf40e1c22721cd23bb6b4b43500.tar.xz |
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
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/read-cache.c b/read-cache.c index 9cff715d6..8d71860f6 100644 --- a/read-cache.c +++ b/read-cache.c @@ -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) |