Browse code

core: rvalue - link to free at end of rve_opt_01() instead on replace

- debug mode messages print fields

(cherry picked from commit 7652f79640b3e792baa77531e697fd74a1ab4584)
(cherry picked from commit 05f60d4d4a20d127a23bf6e42853060a757434a6)

Daniel-Constantin Mierla authored on 06/04/2021 15:23:16 • Henning Westerholt committed on 22/10/2021 11:42:15
Showing 1 changed files
... ...
@@ -3101,6 +3101,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
3101 3101
 	struct rvalue* rv;
3102 3102
 	struct rval_expr* ct_rve;
3103 3103
 	struct rval_expr* v_rve;
3104
+	struct rval_expr* r_rve = NULL;
3104 3105
 	int i;
3105 3106
 	int ret;
3106 3107
 	enum rval_expr_op op;
... ...
@@ -3124,7 +3125,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
3124 3125
 			pos=(e)->fpos; \
3125 3126
 			*(e)=*(v); /* replace e with v (in-place) */ \
3126 3127
 			(e)->fpos=pos; \
3127
-			pkg_free((v)); /* rve_destroy(v_rve) would free everything*/ \
3128
+			r_rve = v; /* link to free it */ \
3128 3129
 		}else{\
3129 3130
 			/* unknown type or str => (int) $v */ \
3130 3131
 			(e)->op=RVE_##ctype##_OP; \
... ...
@@ -3480,9 +3481,11 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
3480 3481
 		}
3481 3482
 	}
3482 3483
 	if (rv) rval_destroy(rv);
3484
+	if (r_rve) pkg_free(r_rve); /* rve_destroy(v_rve) would free everything*/
3483 3485
 	return ret;
3484 3486
 error:
3485 3487
 	if (rv) rval_destroy(rv);
3488
+	if (r_rve) pkg_free(r_rve); /* rve_destroy(v_rve) would free everything*/
3486 3489
 	return -1;
3487 3490
 }
3488 3491