aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-11-13 08:30:25 +0100
committerGitHub <noreply@github.com>2017-11-13 08:30:25 +0100
commit8fff2ef74aae47042c4ee903ae996aa789787fe1 (patch)
treee23eee0161664ccba459f366503d27d1e94ce2f0 /src/nvim/fileio.c
parent8d8212d384f668e4e6dfea64e169ec85daef44a2 (diff)
downloadrneovim-8fff2ef74aae47042c4ee903ae996aa789787fe1.tar.gz
rneovim-8fff2ef74aae47042c4ee903ae996aa789787fe1.tar.bz2
rneovim-8fff2ef74aae47042c4ee903ae996aa789787fe1.zip
vim-patch:8.0.0227 (#7548)
Problem: Crash when 'fileformat' is forced to "dos" and the first line in the file is empty and does not have a CR character. Solution: Don't check for CR before the start of the buffer. https://github.com/vim/vim/commit/2aa5f696b91a51f29873e340de4bdc182e1e8dd4
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index a7676e88f0..ae6c3f96e3 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -1622,7 +1622,8 @@ rewind_retry:
*ptr = NUL; /* end of line */
len = (colnr_T)(ptr - line_start + 1);
if (fileformat == EOL_DOS) {
- if (ptr[-1] == CAR) { /* remove CR */
+ if (ptr > line_start && ptr[-1] == CAR) {
+ // remove CR before NL
ptr[-1] = NUL;
len--;
} else if (ff_error != EOL_DOS) {