aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2014-10-26 20:03:02 +0000
committerJustin M. Keyes <justinkz@gmail.com>2014-10-26 20:03:02 +0000
commit49d5ed55914b5af32abcb87b6b422f880dc1d0d0 (patch)
tree39011f1f5c655b73c35465f74b9428ba9df34c10 /src
parent3fc542b45bc6b3b826f7c2eabffe1ede3cb7afbf (diff)
downloadrneovim-49d5ed55914b5af32abcb87b6b422f880dc1d0d0.tar.gz
rneovim-49d5ed55914b5af32abcb87b6b422f880dc1d0d0.tar.bz2
rneovim-49d5ed55914b5af32abcb87b6b422f880dc1d0d0.zip
fix #1027: :wundo segfault in new, non-empty buffer
Diffstat (limited to 'src')
-rw-r--r--src/nvim/undo.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index fe782053a7..7a57f70498 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -1009,7 +1009,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
int fd;
FILE *fp = NULL;
int perm;
- int write_ok = FALSE;
+ bool write_ok = false;
if (name == NULL) {
file_name = u_get_undo_file_name(buf->b_ffname, FALSE);
@@ -1116,7 +1116,8 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
*/
FileInfo file_info_old;
FileInfo file_info_new;
- if (os_fileinfo((char *)buf->b_ffname, &file_info_old)
+ if (buf->b_ffname != NULL
+ && os_fileinfo((char *)buf->b_ffname, &file_info_old)
&& os_fileinfo((char *)file_name, &file_info_new)
&& file_info_old.stat.st_gid != file_info_new.stat.st_gid
&& os_fchown(fd, -1, file_info_old.stat.st_gid) != 0) {
@@ -1177,7 +1178,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
}
if (put_bytes(fp, (long_u)UF_HEADER_END_MAGIC, 2) == OK)
- write_ok = TRUE;
+ write_ok = true;
#ifdef U_DEBUG
if (headers_written != buf->b_u_numhead) {
EMSGN("Written %" PRId64 " headers, ...", headers_written);