From 0854ccaa22f092f1d59b41d8ee17936b7e900a3f Mon Sep 17 00:00:00 2001 From: Matthias Wahl Date: Thu, 27 Sep 2018 11:47:30 +0200 Subject: [PATCH] free orig ast if we made a copy in lookup_nominal --- src/libponyc/type/lookup.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libponyc/type/lookup.c b/src/libponyc/type/lookup.c index c93319caa4..12975a3510 100644 --- a/src/libponyc/type/lookup.c +++ b/src/libponyc/type/lookup.c @@ -217,10 +217,17 @@ static deferred_reification_t* lookup_nominal(pass_opt_t* opt, ast_t* from, ast_t* typeargs = ast_childidx(type, 2); + ast_t* orig_initial = orig; if(ast_id(find) == TK_FUN && ast_id(ast_child(find)) == TK_BOX) orig = downcast_iso_trn_receiver_to_ref(orig); - return deferred_reify_new(find, typeparams, typeargs, orig); + deferred_reification_t* reified = deferred_reify_new(find, typeparams, typeargs, orig); + + // free if we made a copy of orig + if(orig != orig_initial) + ast_free(orig); + + return reified; } static deferred_reification_t* lookup_typeparam(pass_opt_t* opt, ast_t* from,