mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
fix: guard against empty key value in parse_object_body
This commit is contained in:
@@ -264,13 +264,17 @@ parse_object_body :: proc(p: ^Parser, end_token: Token_Kind) -> (obj: Object, er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
insert_success := runtime.map_insert(&obj, key, elem)
|
// NOTE(gonz): There are code paths for which this traversal ends up
|
||||||
// NOTE(gonz): we'd rather check specifically for an allocation error here but
|
// inserting empty key/values into the object and for those we do not
|
||||||
// `map_insert` doesn't differentiate; we can only check for `nil`
|
// want to allocate anything
|
||||||
if insert_success == nil {
|
if key != "" {
|
||||||
return nil, .Out_Of_Memory
|
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) {
|
if parse_comma(p) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user