mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
eval/typval_encode: Fix infinite loop
Occurs when trying to dump a partial with attached self dictionary which references that partial. “Infinite” loop should normally result in Neovim killed by OOM killer. Also moved the place when partials are unreferenced by clear_tv: from …FUNC_START to …FUNC_END.
This commit is contained in:
@@ -9,6 +9,7 @@ local redir_exec = helpers.redir_exec
|
||||
local funcs = helpers.funcs
|
||||
local write_file = helpers.write_file
|
||||
local NIL = helpers.NIL
|
||||
local source = helpers.source
|
||||
|
||||
describe('string() function', function()
|
||||
before_each(clear)
|
||||
@@ -137,6 +138,18 @@ describe('string() function', function()
|
||||
it('dumps references to script functions', function()
|
||||
eq('function(\'<SNR>1_Test2\')', eval('string(Test2_f)'))
|
||||
end)
|
||||
|
||||
it('dumps partials with self referencing a partial', function()
|
||||
source([[
|
||||
function TestDict() dict
|
||||
endfunction
|
||||
let d = {}
|
||||
let TestDictRef = function('TestDict', d)
|
||||
let d.tdr = TestDictRef
|
||||
]])
|
||||
eq("\nE724: unable to correctly dump variable with self-referencing container\nfunction('TestDict', {'tdr': function('TestDict', {E724@1})})",
|
||||
redir_exec('echo string(d.tdr)'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('used to represent lists', function()
|
||||
|
||||
Reference in New Issue
Block a user