mirror of
https://github.com/neovim/neovim.git
synced 2026-11-06 05:16:52 +00:00
Problem: - `json_encode()` leaks the conversion stack if a dict key nested more than 8 levels deep is invalid UTF-8, and leaks the string of an invalid special string (`v:msgpack_types.string`). - Lua conversion passes the total stack size to `lua_checkstack()`, which expects the extra slots, so it fails at half the real limit. - If `nlua_push_typval()` fails, the Lua stack is not restored: e.g. `vim.g.x` returns part of the half-built value. Solution: - `encode_vim_to_*()` owns the conversion state, so converter macros may return at any point. - Check the Lua stack once per value, for 3 extra slots. - Restore the Lua stack and push nil on failure.