X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=xdiff-interface.c;h=164581f87f49935f0d1b1885420960a4d11dea56;hb=e2895de4d8efef52e835731aaaaa9467e2110e62;hp=cd2285de1cb1faa9f7c6c97dd22210f20bb046a3;hpb=e250c5914fd151caf228cbda6c30560c266bcfef;p=git.git diff --git a/xdiff-interface.c b/xdiff-interface.c index cd2285de1..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; @@ -286,9 +288,8 @@ static long ff_regexp(const char *line, long len, result = pmatch[i].rm_eo - pmatch[i].rm_so; if (result > buffer_size) result = buffer_size; - else - while (result > 0 && (isspace(line[result - 1]))) - result--; + while (result > 0 && (isspace(line[result - 1]))) + result--; memcpy(buffer, line, result); fail: free(line_buffer);