Commits

Anonymous committed 26517de Merge

Merge branch 'rs/maint-diff-fd-leak' into maint

* rs/maint-diff-fd-leak:
close file on error in read_mmfile()

Comments (0)

Files changed (1)

xdiff-interface.c

 		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;