diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-03-04 14:19:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-04 14:19:53 +0800 |
commit | de14f2c928f913d4fb617d693024eec5cf2223ec (patch) | |
tree | 34e2b7c7324382eb0058e1dffa2d1baa1ab2ae0d /src/nvim/lua/executor.c | |
parent | 446c353a507834a3cbe9007b06e7e0c2c46b5ac7 (diff) | |
parent | b7d59649acf43c76cc72b25c04bcae926a40b4fe (diff) | |
download | rneovim-de14f2c928f913d4fb617d693024eec5cf2223ec.tar.gz rneovim-de14f2c928f913d4fb617d693024eec5cf2223ec.tar.bz2 rneovim-de14f2c928f913d4fb617d693024eec5cf2223ec.zip |
Merge pull request #22506 from zeertzjq/vim-9.0.0013
vim-patch:9.0.{partial:0013,0016}: fix memory access errors
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r-- | src/nvim/lua/executor.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index c8fc76e20d..bb461a7f13 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1706,7 +1706,9 @@ void ex_luado(exarg_T *const eap) break; } lua_pushvalue(lstate, -1); - const char *old_line = (const char *)ml_get_buf(curbuf, l, false); + const char *const old_line = (const char *)ml_get_buf(curbuf, l, false); + // Get length of old_line here as calling Lua code may free it. + const size_t old_line_len = strlen(old_line); lua_pushstring(lstate, old_line); lua_pushnumber(lstate, (lua_Number)l); if (nlua_pcall(lstate, 2, 1)) { @@ -1714,8 +1716,6 @@ void ex_luado(exarg_T *const eap) break; } if (lua_isstring(lstate, -1)) { - size_t old_line_len = strlen(old_line); - size_t new_line_len; const char *const new_line = lua_tolstring(lstate, -1, &new_line_len); char *const new_line_transformed = xmemdupz(new_line, new_line_len); |