From 43a22d7492c89ca60aadf3e445e73e21f7ee12f0 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 22 Apr 2018 21:24:43 -0700 Subject: [PATCH] Ensure reference is always initialized. --- src/parser.c | 6 +++++- src/util.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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); }