summaryrefslogtreecommitdiffstats
path: root/src/if_lua.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-29 22:48:45 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-29 22:48:45 +0100
commitd58f03b1c21b5b0242718f89da53ddd67b1eff6b (patch)
tree8d26ad06a50967f6e14eb24e2556e38bae7091ae /src/if_lua.c
parent6fe2eb43d2527cc8a3450456a60639e87f16d32d (diff)
patch 8.0.0268: may get ml_get error when :luado deletes linesv8.0.0268
Problem: May get ml_get error when :luado deletes lines or switches to another buffer. (Nikolai Pavlov, issue #1421) Solution: Check the buffer and line every time.
Diffstat (limited to 'src/if_lua.c')
-rw-r--r--src/if_lua.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/if_lua.c b/src/if_lua.c
index b77a3cd5dd..ad8ee1bf0c 100644
--- a/src/if_lua.c
+++ b/src/if_lua.c
@@ -1716,6 +1716,8 @@ ex_luado(exarg_T *eap)
const char *s = (const char *) eap->arg;
luaL_Buffer b;
size_t len;
+ buf_T *was_curbuf = curbuf;
+
if (lua_init() == FAIL) return;
if (u_save(eap->line1 - 1, eap->line2 + 1) == FAIL)
{
@@ -1739,6 +1741,10 @@ ex_luado(exarg_T *eap)
lua_replace(L, -2); /* function -> body */
for (l = eap->line1; l <= eap->line2; l++)
{
+ /* Check the line number, the command my have deleted lines. */
+ if (l > curbuf->b_ml.ml_line_count)
+ break;
+
lua_pushvalue(L, -1); /* function */
luaV_pushline(L, curbuf, l); /* current line as arg */
lua_pushinteger(L, l); /* current line number as arg */
@@ -1747,6 +1753,9 @@ ex_luado(exarg_T *eap)
luaV_emsg(L);
break;
}
+ /* Catch the command switching to another buffer. */
+ if (curbuf != was_curbuf)
+ break;
if (lua_isstring(L, -1)) /* update line? */
{
#ifdef HAVE_SANDBOX