Browse code

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

- debug mode messages print fields

Daniel-Constantin Mierla authored on 06/04/2021 15:23:16
Showing 1 changed files
... ...
@@ -3185,6 +3185,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
3185 3185
 	struct rvalue* rv;
3186 3186
 	struct rval_expr* ct_rve;
3187 3187
 	struct rval_expr* v_rve;
3188
+	struct rval_expr* r_rve = NULL;
3188 3189
 	int i;
3189 3190
 	int ret;
3190 3191
 	enum rval_expr_op op;
... ...
@@ -3208,7 +3209,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
3208 3209
 			pos=(e)->fpos; \
3209 3210
 			*(e)=*(v); /* replace e with v (in-place) */ \
3210 3211
 			(e)->fpos=pos; \
3211
-			pkg_free((v)); /* rve_destroy(v_rve) would free everything*/ \
3212
+			r_rve = v; /* link to free it */ \
3212 3213
 		}else{\
3213 3214
 			/* unknown type or str => (int) $v */ \
3214 3215
 			(e)->op=RVE_##ctype##_OP; \
... ...
@@ -3564,9 +3565,11 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
3564 3565
 		}
3565 3566
 	}
3566 3567
 	if (rv) rval_destroy(rv);
3568
+	if (r_rve) pkg_free(r_rve); /* rve_destroy(v_rve) would free everything*/
3567 3569
 	return ret;
3568 3570
 error:
3569 3571
 	if (rv) rval_destroy(rv);
3572
+	if (r_rve) pkg_free(r_rve); /* rve_destroy(v_rve) would free everything*/
3570 3573
 	return -1;
3571 3574
 }
3572 3575