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