summaryrefslogtreecommitdiff
path: root/xdiff-interface.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2010-12-25 12:38:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-12-26 19:17:18 (GMT)
commit5fd898141ce2a243abf75192c9a55cb0a4e1ba80 (patch)
tree2bf2e8e97aff23a95377399c8b0309fc66810d26 /xdiff-interface.c
parentabf411e28d9df669b0e690578a1eb95c0bd29847 (diff)
downloadgit-5fd898141ce2a243abf75192c9a55cb0a4e1ba80.zip
git-5fd898141ce2a243abf75192c9a55cb0a4e1ba80.tar.gz
git-5fd898141ce2a243abf75192c9a55cb0a4e1ba80.tar.bz2
close file on error in read_mmfile()
Reported in http://qa.debian.org/daca/cppcheck/sid/git_1.7.2.3-2.2.html and in http://thread.gmane.org/gmane.comp.version-control.git/123042. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 01f14fb..b78f757 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -211,8 +211,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;