diff --git a/flamingo/val.c b/flamingo/val.c index 062878e..5263c75 100644 --- a/flamingo/val.c +++ b/flamingo/val.c @@ -87,6 +87,10 @@ static void val_free(flamingo_val_t* val) { } static flamingo_val_t* val_decref(flamingo_val_t* val) { + if (val == NULL) { + return NULL; + } + val->ref_count--; if (val->ref_count > 0) { diff --git a/questions.md b/questions.md index eba68dd..f3fb7c6 100644 --- a/questions.md +++ b/questions.md @@ -6,3 +6,5 @@ I'm keeping track of these so I don't forget why I did something a certain way a *Q:* Should I really be passing TSNode everywhere instead of TSNode*? It feels like this is prone to me being like "oh, well, the TSNode type is probably hiding a pointer if it's being used as an argument, so I don't have to worry about out-of-scope usage". *A:* Yes. Tree-sitter passes them as values, so be consistent with that. + +*Q:* Do gently detached scopes need to be freed or are they already?