diff --git a/src/parser.c b/src/parser.c index 83f67dc..8d1c5ac 100644 --- a/src/parser.c +++ b/src/parser.c @@ -324,9 +324,13 @@ libab_result _parse_type(struct parser_state* state, libab_ref* into) { result = libab_ref_new(into, store_into, _parse_type_free); if (result != LIBAB_SUCCESS) { libab_parsetype_free(store_into); - libab_ref_null(into); } } + + if(result != LIBAB_SUCCESS) { + libab_ref_null(into); + } + return result; } diff --git a/src/util.c b/src/util.c index 58167d9..4048b26 100644 --- a/src/util.c +++ b/src/util.c @@ -114,6 +114,7 @@ libab_result libab_instantiate_basetype(libab_basetype* to_instantiate, } if(result != LIBAB_SUCCESS) { + libab_ref_null(into); free(parsetype); }