mirror of
https://github.com/git/git
synced 2024-07-04 16:48:40 +00:00
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>
This commit is contained in:
parent
abf411e28d
commit
5fd898141c
|
@ -211,8 +211,10 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
|
||||||
return error("Could not open %s", filename);
|
return error("Could not open %s", filename);
|
||||||
sz = xsize_t(st.st_size);
|
sz = xsize_t(st.st_size);
|
||||||
ptr->ptr = xmalloc(sz ? sz : 1);
|
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);
|
return error("Could not read %s", filename);
|
||||||
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
ptr->size = sz;
|
ptr->size = sz;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user