]> asedeno.scripts.mit.edu Git - git.git/blobdiff - xdiff-interface.c
merge-file: handle empty files gracefully
[git.git] / xdiff-interface.c
index 4b8e5cca804198b0e227454a585fa025281bbe2d..d8ba7e725fd30f2dde51a2b45ed0b6c9292bfce0 100644 (file)
@@ -152,8 +152,8 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
        if ((f = fopen(filename, "rb")) == NULL)
                return error("Could not open %s", filename);
        sz = xsize_t(st.st_size);
-       ptr->ptr = xmalloc(sz);
-       if (fread(ptr->ptr, sz, 1, f) != 1)
+       ptr->ptr = xmalloc(sz ? sz : 1);
+       if (sz && fread(ptr->ptr, sz, 1, f) != 1)
                return error("Could not read %s", filename);
        fclose(f);
        ptr->size = sz;