diff --git a/src/ca65/expr.c b/src/ca65/expr.c index 22eace8a4..b5beb8e78 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -923,18 +923,24 @@ long ConstExpression (void) * not constant. */ { + long Val; + /* Read the expression, and call finalize (exception here, since we * expect a const). */ ExprNode* Expr = FinalizeExpr (Expression ()); - /* Return the value */ + /* Get the value */ if (IsConstExpr (Expr)) { - return GetExprVal (Expr); + Val = GetExprVal (Expr); } else { Error (ERR_CONSTEXPR_EXPECTED); - return 0; + Val = 0; } + + /* Free the expression tree and return the value */ + FreeExpr (Expr); + return Val; } @@ -1644,4 +1650,4 @@ void WriteExpr (ExprNode* Expr) - + diff --git a/src/ca65/segment.c b/src/ca65/segment.c index 3e50d96ac..8fd5e356f 100644 --- a/src/ca65/segment.c +++ b/src/ca65/segment.c @@ -370,6 +370,9 @@ void SegCheck (void) } } + /* We don't need the expression tree any longer */ + FreeExpr (F->V.Expr); + /* Convert the fragment into a literal fragment */ for (I = 0; I < F->Len; ++I) { F->V.Data [I] = Val & 0xFF;