mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-18 17:02:06 +03:00
Json: Fix buffer overflow when reading json finishing with { or [
Fixes #1860
This commit is contained in:
parent
9755f7f8f2
commit
fec34c3748
@ -296,7 +296,9 @@ parse_json(const char* pos, const char* end)
|
|||||||
if (*pos == '[')
|
if (*pos == '[')
|
||||||
{
|
{
|
||||||
JsonArray array;
|
JsonArray array;
|
||||||
if (*++pos == ']')
|
if (++pos == end)
|
||||||
|
throw runtime_error("unable to parse array");
|
||||||
|
if (*pos == ']')
|
||||||
return Result{std::move(array), pos+1};
|
return Result{std::move(array), pos+1};
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@ -319,8 +321,10 @@ parse_json(const char* pos, const char* end)
|
|||||||
}
|
}
|
||||||
if (*pos == '{')
|
if (*pos == '{')
|
||||||
{
|
{
|
||||||
|
if (++pos == end)
|
||||||
|
throw runtime_error("unable to parse object");
|
||||||
JsonObject object;
|
JsonObject object;
|
||||||
if (*++pos == '}')
|
if (*pos == '}')
|
||||||
return Result{std::move(object), pos+1};
|
return Result{std::move(object), pos+1};
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
Loading…
Reference in New Issue
Block a user