0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.4070: using uninitialized memory when reading empty file

Problem:    Using uninitialized memory when reading empty file.
Solution:   Check for empty file before checking for NL. (Dominique Pellé,
            closes #9511)
This commit is contained in:
Dominique Pelle
2022-01-12 15:24:40 +00:00
committed by Bram Moolenaar
parent 5d9826973d
commit f5d639a8af
3 changed files with 10 additions and 1 deletions

View File

@@ -1796,7 +1796,7 @@ read_file_or_blob(typval_T *argvars, typval_T *rettv, int always_blob)
p < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary));
++p)
{
if (*p == '\n' || readlen <= 0)
if (readlen <= 0 || *p == '\n')
{
listitem_T *li;
char_u *s = NULL;