mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-30 11:20:08 +00:00
Merge pull request #2838 from GoNZooo/gonz.return-out-of-memory-in-json-parse
fix(json): return `.Out_Of_Memory` when out of memory on parse
This commit is contained in:
@@ -263,8 +263,17 @@ parse_object_body :: proc(p: ^Parser, end_token: Token_Kind) -> (obj: Object, er
|
||||
return
|
||||
}
|
||||
|
||||
obj[key] = elem
|
||||
|
||||
// NOTE(gonz): There are code paths for which this traversal ends up
|
||||
// inserting empty key/values into the object and for those we do not
|
||||
// want to allocate anything
|
||||
if key != "" {
|
||||
reserve_error := reserve(&obj, len(obj) + 1)
|
||||
if reserve_error == mem.Allocator_Error.Out_Of_Memory {
|
||||
return nil, .Out_Of_Memory
|
||||
}
|
||||
obj[key] = elem
|
||||
}
|
||||
|
||||
if parse_comma(p) {
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user