From 3bbec871e43069071f01d2c53692aba442fb713e Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 2 Nov 2018 13:47:00 +0100 Subject: [PATCH] tinyexpr: Free all parameters again This used implicit fallthrough to free all. We still iterate back-to-front (i--) because maybe that's important? --- src/tinyexpr.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tinyexpr.cpp b/src/tinyexpr.cpp index d9b6887bb..8d955d274 100644 --- a/src/tinyexpr.cpp +++ b/src/tinyexpr.cpp @@ -110,8 +110,12 @@ static te_expr *new_expr(const int type, const te_expr *parameters[]) { void te_free_parameters(te_expr *n) { if (!n) return; - const int arity = get_arity(n->type); - if (arity > 0) te_free((te_expr *)n->parameters[arity - 1]); + int arity = get_arity(n->type); + // Free all parameters from the back to the front. + while (arity > 0) { + te_free((te_expr *)n->parameters[arity - 1]); + arity--; + } }