eval/decode: Make sure that error messages do not cause overflow

This commit is contained in:
ZyX
2016-03-07 08:54:39 +03:00
parent 52c6cc2189
commit eb806c9620
5 changed files with 134 additions and 58 deletions

View File

@@ -448,6 +448,12 @@ describe('json_decode() function', function()
sp_decode_eq({_TYPE='string', _VAL={'\n\xAB\n'}}, '"\\u0000\\u00AB\\u0000"')
end)
it('fails to convert string to latin1 if it is impossible', function()
restart('set encoding=latin1')
eq('Vim(call):E474: Failed to convert string "ꯍ" from UTF-8',
exc_exec('call json_decode(\'"\\uABCD"\')'))
end)
it('parses U+00C3 correctly', function()
eq('\xC3\x83', funcs.json_decode('"\xC3\x83"'))
end)