summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1affea4)
raw | patch | inline | side by side (parent: 1affea4)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Thu, 13 Mar 2008 15:19:35 +0000 (16:19 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 14 Mar 2008 06:43:56 +0000 (23:43 -0700) |
Earlier, it would error out while trying to read and/or writing them.
Now, calling merge-file with empty files is neither interesting nor
useful, but it is a bug that needed fixing.
Noticed by Clemens Buchacher.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Now, calling merge-file with empty files is neither interesting nor
useful, but it is a bug that needed fixing.
Noticed by Clemens Buchacher.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
builtin-merge-file.c | patch | blob | history | |
xdiff-interface.c | patch | blob | history |
diff --git a/builtin-merge-file.c b/builtin-merge-file.c
index 58deb62ac08507901c40e89aec0cea7fcdc78f1e..baff4495f0a4cbe6e5cf94975110e6ddd5518c20 100644 (file)
--- a/builtin-merge-file.c
+++ b/builtin-merge-file.c
if (!f)
ret = error("Could not open %s for writing", filename);
- else if (fwrite(result.ptr, result.size, 1, f) != 1)
+ else if (result.size &&
+ fwrite(result.ptr, result.size, 1, f) != 1)
ret = error("Could not write to %s", filename);
else if (fclose(f))
ret = error("Could not close %s", filename);
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 4b8e5cca804198b0e227454a585fa025281bbe2d..d8ba7e725fd30f2dde51a2b45ed0b6c9292bfce0 100644 (file)
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
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;