aboutsummaryrefslogtreecommitdiff
path: root/xdiff-interface.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-12-26 11:18:39 -0800
committerJunio C Hamano <gitster@pobox.com>2010-12-26 11:18:39 -0800
commit26517dea245cc6332ffb80cf7747f6c211aa2e4d (patch)
treedfc1e285f9e30d7f2d4f81257dbc826a1cfb4727 /xdiff-interface.c
parentc2ed29b49b557b7bba8be147551cdd6e22fd743b (diff)
parent5fd898141ce2a243abf75192c9a55cb0a4e1ba80 (diff)
downloadgit-26517dea245cc6332ffb80cf7747f6c211aa2e4d.tar.gz
git-26517dea245cc6332ffb80cf7747f6c211aa2e4d.tar.xz
Merge branch 'rs/maint-diff-fd-leak' into maint
* rs/maint-diff-fd-leak: close file on error in read_mmfile()
Diffstat (limited to 'xdiff-interface.c')
-rw-r--r--xdiff-interface.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/xdiff-interface.c b/xdiff-interface.c
index e1e054e4d..164581f87 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -212,8 +212,10 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
return error("Could not open %s", filename);
sz = xsize_t(st.st_size);
ptr->ptr = xmalloc(sz ? sz : 1);
- if (sz && fread(ptr->ptr, sz, 1, f) != 1)
+ if (sz && fread(ptr->ptr, sz, 1, f) != 1) {
+ fclose(f);
return error("Could not read %s", filename);
+ }
fclose(f);
ptr->size = sz;
return 0;