mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(eval): prevent double-free in garbage collection (#22990)
This commit is contained in:
parent
5ed7ede1f5
commit
0e4086b741
@ -1149,7 +1149,7 @@ void vars_clear_ext(hashtab_T *ht, int free_val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hash_clear(ht);
|
hash_clear(ht);
|
||||||
ht->ht_used = 0;
|
hash_init(ht);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delete a variable from hashtab "ht" at item "hi".
|
/// Delete a variable from hashtab "ht" at item "hi".
|
||||||
|
@ -220,3 +220,38 @@ describe('listing functions using :function', function()
|
|||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('no double-free in garbage collection #16287', function()
|
||||||
|
clear()
|
||||||
|
-- Don't use exec() here as using a named script reproduces the issue better.
|
||||||
|
write_file('Xgarbagecollect.vim', [[
|
||||||
|
func Foo() abort
|
||||||
|
let s:args = [a:000]
|
||||||
|
let foo0 = ""
|
||||||
|
let foo1 = ""
|
||||||
|
let foo2 = ""
|
||||||
|
let foo3 = ""
|
||||||
|
let foo4 = ""
|
||||||
|
let foo5 = ""
|
||||||
|
let foo6 = ""
|
||||||
|
let foo7 = ""
|
||||||
|
let foo8 = ""
|
||||||
|
let foo9 = ""
|
||||||
|
let foo10 = ""
|
||||||
|
let foo11 = ""
|
||||||
|
let foo12 = ""
|
||||||
|
let foo13 = ""
|
||||||
|
let foo14 = ""
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
set updatetime=1
|
||||||
|
call Foo()
|
||||||
|
call Foo()
|
||||||
|
]])
|
||||||
|
finally(function()
|
||||||
|
os.remove('Xgarbagecollect.vim')
|
||||||
|
end)
|
||||||
|
command('source Xgarbagecollect.vim')
|
||||||
|
sleep(10)
|
||||||
|
assert_alive()
|
||||||
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user