File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ static Expr* foldBinary(Expr* expr) {
3939 else folded = false;
4040
4141 if (folded ) {
42+ free (expr -> as .binary .operator );
4243 expr -> type = EXPR_LITERAL ;
4344 expr -> as .literal .value = res ;
4445 freeExpr (l );
@@ -60,14 +61,18 @@ static Expr* foldUnary(Expr* expr) {
6061 const char * op = expr -> as .unary .operator ;
6162
6263 if (strcmp (op , "-" ) == 0 && IS_NUMBER (rv )) {
64+ free (expr -> as .unary .operator );
6365 expr -> type = EXPR_LITERAL ;
6466 expr -> as .literal .value = NUMBER_VAL (- AS_NUMBER (rv ));
67+ freeExpr (r );
6568 return expr ;
6669 } else if (strcmp (op , "!" ) == 0 ) {
6770 // isFalsey logic
6871 bool res = IS_NIL (rv ) || (IS_BOOL (rv ) && !AS_BOOL (rv ));
72+ free (expr -> as .unary .operator );
6973 expr -> type = EXPR_LITERAL ;
7074 expr -> as .literal .value = BOOL_VAL (res );
75+ freeExpr (r );
7176 return expr ;
7277 }
7378 }
You can’t perform that action at this time.
0 commit comments