mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(context): don't leak memory on multiple invalid objects (#25979)
This commit is contained in:
parent
e9b9a86cd5
commit
fdaf6bc557
@ -380,7 +380,7 @@ int ctx_from_dict(Dictionary dict, Context *ctx, Error *err)
|
||||
assert(ctx != NULL);
|
||||
|
||||
int types = 0;
|
||||
for (size_t i = 0; i < dict.size; i++) {
|
||||
for (size_t i = 0; i < dict.size && !ERROR_SET(err); i++) {
|
||||
KeyValuePair item = dict.items[i];
|
||||
if (item.value.type != kObjectTypeArray) {
|
||||
continue;
|
||||
|
@ -1982,7 +1982,7 @@ describe('API', function()
|
||||
|
||||
it('errors when context dictionary is invalid', function()
|
||||
eq('E474: Failed to convert list to msgpack string buffer',
|
||||
pcall_err(nvim, 'load_context', { regs = { {} } }))
|
||||
pcall_err(nvim, 'load_context', { regs = { {} }, jumps = { {} } }))
|
||||
eq("Empty dictionary keys aren't allowed",
|
||||
pcall_err(nvim, 'load_context', { regs = { { [''] = '' } } }))
|
||||
end)
|
||||
|
@ -378,7 +378,7 @@ describe('context functions', function()
|
||||
it('errors when context dictionary is invalid', function()
|
||||
call('ctxpush')
|
||||
eq('Vim:E474: Failed to convert list to msgpack string buffer',
|
||||
pcall_err(call, 'ctxset', { regs = { {} } }))
|
||||
pcall_err(call, 'ctxset', { regs = { {} }, jumps = { {} } }))
|
||||
end)
|
||||
|
||||
it('sets context dictionary at index in context stack', function()
|
||||
|
Loading…
Reference in New Issue
Block a user