]> granicus.if.org Git - vim/commitdiff
patch 8.2.3234: crash when printing long string with Lua v8.2.3234
authorBram Moolenaar <Bram@vim.org>
Wed, 28 Jul 2021 13:07:01 +0000 (15:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 28 Jul 2021 13:07:01 +0000 (15:07 +0200)
Problem:    Crash when printing long string with Lua.
Solution:   Remove lua_pop(). (Martin Tournoij, closes #8648)

src/if_lua.c
src/testdir/test_lua.vim
src/version.c

index 82dffb0bafddf6fb68107b6d31bab36b1d5cd6f2..79fb68168bbedbb57327f4185f08c8060fb6627d 100644 (file)
@@ -1734,9 +1734,9 @@ luaV_print(lua_State *L)
        s = lua_tolstring(L, -1, &l);
        if (s == NULL)
            return luaL_error(L, "cannot convert to string");
-       if (i > 1) luaL_addchar(&b, ' '); // use space instead of tab
+       if (i > 1)
+           luaL_addchar(&b, ' '); // use space instead of tab
        luaV_addlstring(&b, s, l, 0);
-       lua_pop(L, 1);
     }
     luaL_pushresult(&b);
     if (!got_int)
index c3305631909ff0c8196c5be8b28270a4fd0c0a29..2f204048f6f3c51ab12eb65bd24bfbdcec862c54 100644 (file)
@@ -850,6 +850,24 @@ func Test_luafile_error()
   bwipe!
 endfunc
 
+" Test :luafile printing a long string
+func Test_luafile_print()
+  new Xlua_file
+  let lines =<< trim END
+      local data = ''
+      for i = 1, 130 do
+       data = data .. 'xxxxx asd as as dad sad sad xz cxz  czxcxzczxc ad ad asd asd asd asd asd'
+      end
+      print(data)
+  END
+  call setline(1, lines)
+  w
+  luafile %
+
+  call delete('Xlua_file')
+  bwipe!
+endfunc
+
 " Test for dealing with strings containing newlines and null character
 func Test_lua_string_with_newline()
   let x = execute('lua print("Hello\nWorld")')
index b17233398abfb288e45047ca2b59c838896b0e09..fa54081cae907bf13832d50b7f648abc45cad5c3 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3234,
 /**/
     3233,
 /**/