diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-05-25 22:09:21 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-05-25 22:09:21 +0200 |
commit | 83ad0147c02606ad1d32f62e84b65402bca9efec (patch) | |
tree | 3e5a4b30568330717c7758ce2e213beaa909bdec /src/undo.c | |
parent | 64354da438bc99a366a14f391f85c23af2907eb9 (diff) | |
download | vim-git-83ad0147c02606ad1d32f62e84b65402bca9efec.tar.gz |
Fix for using ":wundo foo" when foo is an empty file.
Diffstat (limited to 'src/undo.c')
-rw-r--r-- | src/undo.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/undo.c b/src/undo.c index 35fa31064..787f62590 100644 --- 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"), |