Mercurial > vim
diff src/memline.c @ 16786:98ca522e6453 v8.1.1395
patch 8.1.1395: saving for undo may access invalid memory
commit https://github.com/vim/vim/commit/adfde115d5c9c9ac4a052874bcf85d2507fe1355
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 25 22:11:45 2019 +0200
patch 8.1.1395: saving for undo may access invalid memory
Problem: Saving for undo may access invalid memory. (Dominique Pelle)
Solution: Set ml_line_len also when returning a constant string.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 25 May 2019 22:15:04 +0200 |
parents | ef00b6bc186b |
children | ce04ebdf26b8 |
line wrap: on
line diff
--- a/src/memline.c +++ b/src/memline.c @@ -2573,13 +2573,17 @@ ml_get_buf( } errorret: STRCPY(IObuff, "???"); + buf->b_ml.ml_line_len = 4; return IObuff; } - if (lnum <= 0) /* pretend line 0 is line 1 */ + if (lnum <= 0) // pretend line 0 is line 1 lnum = 1; - if (buf->b_ml.ml_mfp == NULL) /* there are no lines */ + if (buf->b_ml.ml_mfp == NULL) // there are no lines + { + buf->b_ml.ml_line_len = 1; return (char_u *)""; + } /* * See if it is the same line as requested last time.