]> granicus.if.org Git - vim/commitdiff
Fix for using ":wundo foo" when foo is an empty file.
authorBram Moolenaar <Bram@vim.org>
Tue, 25 May 2010 20:09:21 +0000 (22:09 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 25 May 2010 20:09:21 +0000 (22:09 +0200)
src/undo.c

index 35fa31064208948d8a61fb35ba7130476a10ca08..787f62590ee769b69be7868537d1fa46f175d648 100644 (file)
@@ -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"),