diff options
author | luukvbaal <luukvbaal@gmail.com> | 2025-02-12 17:20:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-12 08:20:51 -0800 |
commit | 15bc930fca94a43fb5546b48d7c09cf223b63233 (patch) | |
tree | 6da987ed997e4f5b7955522967b4db6a41ff4424 /src | |
parent | be8d87014c0c120ece50aabff307c1f5d9167ec0 (diff) | |
download | rneovim-15bc930fca94a43fb5546b48d7c09cf223b63233.tar.gz rneovim-15bc930fca94a43fb5546b48d7c09cf223b63233.tar.bz2 rneovim-15bc930fca94a43fb5546b48d7c09cf223b63233.zip |
fix(memline): don't check line count for closed memline #32403
Problem: Error thrown when for invalid line number which may be accessed
in an `on_detach` callback at which point line count is
intentionally set to 0.
Solution: Move empty memline check to before line number check.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/memline.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c index fb7fdfb8b2..047bbbfdaa 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1875,6 +1875,11 @@ static char *ml_get_buf_impl(buf_T *buf, linenr_T lnum, bool will_change) static int recursive = 0; static char questions[4]; + if (buf->b_ml.ml_mfp == NULL) { // there are no lines + buf->b_ml.ml_line_len = 1; + return ""; + } + if (lnum > buf->b_ml.ml_line_count) { // invalid line number if (recursive == 0) { // Avoid giving this message for a recursive call, may happen when @@ -1892,11 +1897,6 @@ errorret: } lnum = MAX(lnum, 1); // pretend line 0 is line 1 - if (buf->b_ml.ml_mfp == NULL) { // there are no lines - buf->b_ml.ml_line_len = 1; - return ""; - } - // See if it is the same line as requested last time. // Otherwise may need to flush last used line. // Don't use the last used line when 'swapfile' is reset, need to load all |