changeset 2222:271a5907f944 vim73

Fix for using ":wundo foo" when foo is an empty file.
author Bram Moolenaar <bram@vim.org>
date Tue, 25 May 2010 22:09:21 +0200
parents fef4bd7afb26
children 81b83a19e127
files src/undo.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/undo.c
+++ b/src/undo.c
@@ -1286,11 +1286,12 @@ u_write_undo(name, forceit, buf, hash)
 	    }
 	    else
 	    {
-		char_u buf[2];
+		char_u	buf[2];
+		int	len;
 
-		vim_read(fd, buf, 2);
+		len = vim_read(fd, buf, 2);
 		close(fd);
-		if ((buf[0] << 8) + buf[1] != UF_START_MAGIC)
+		if (len < 2 || (buf[0] << 8) + buf[1] != UF_START_MAGIC)
 		{
 		    if (name != NULL || p_verbose > 0)
 			smsg((char_u *)_("Will not overwrite, this is not an undo file: %s"),