* [PATCH] close file on error in read_mmfile()
@ 2010-12-25 12:38 René Scharfe
2010-12-25 12:44 ` René Scharfe
2010-12-26 19:18 ` Junio C Hamano
0 siblings, 2 replies; 3+ messages in thread
From: René Scharfe @ 2010-12-25 12:38 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano
Reported in http://qa.debian.org/daca/cppcheck/sid/git_1.7.2.3-2.2.html.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
xdiff-interface.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/xdiff-interface.c b/xdiff-interface.c
index cd2285d..cd9fa33 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;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] close file on error in read_mmfile()
2010-12-25 12:38 [PATCH] close file on error in read_mmfile() René Scharfe
@ 2010-12-25 12:44 ` René Scharfe
2010-12-26 19:18 ` Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: René Scharfe @ 2010-12-25 12:44 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Martin Ettl
Am 25.12.2010 13:38, schrieb René Scharfe:
> Reported in http://qa.debian.org/daca/cppcheck/sid/git_1.7.2.3-2.2.html.
Oh, and also in http://thread.gmane.org/gmane.comp.version-control.git/123042.
René
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] close file on error in read_mmfile()
2010-12-25 12:38 [PATCH] close file on error in read_mmfile() René Scharfe
2010-12-25 12:44 ` René Scharfe
@ 2010-12-26 19:18 ` Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2010-12-26 19:18 UTC (permalink / raw)
To: René Scharfe; +Cc: Git Mailing List, Junio C Hamano
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-12-26 19:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-25 12:38 [PATCH] close file on error in read_mmfile() René Scharfe
2010-12-25 12:44 ` René Scharfe
2010-12-26 19:18 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).