diff --git a/flamingo/grammar/map.h b/flamingo/grammar/map.h index a61fe01..75fd8fd 100644 --- a/flamingo/grammar/map.h +++ b/flamingo/grammar/map.h @@ -62,6 +62,10 @@ static int parse_map(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) { vals[count - 1] = v; } + if (val == NULL) { + return 0; + } + assert(*val == NULL); *val = val_alloc(); diff --git a/flamingo/grammar/vec.h b/flamingo/grammar/vec.h index 687dc1f..3411d42 100644 --- a/flamingo/grammar/vec.h +++ b/flamingo/grammar/vec.h @@ -34,6 +34,10 @@ static int parse_vec(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) { elems[elem_count - 1] = elem; } + if (val == NULL) { + return 0; + } + assert(*val == NULL); *val = val_alloc();