core: rvalue - link to free at end of rve_opt_01() instead on replace
authorDaniel-Constantin Mierla <miconda@gmail.com>
Tue, 6 Apr 2021 15:23:16 +0000 (17:23 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Tue, 13 Apr 2021 06:27:21 +0000 (08:27 +0200)
- debug mode messages print fields

(cherry picked from commit 7652f79640b3e792baa77531e697fd74a1ab4584)

src/core/rvalue.c

index d1bf4b5..c60a687 100644 (file)
@@ -3101,6 +3101,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
        struct rvalue* rv;
        struct rval_expr* ct_rve;
        struct rval_expr* v_rve;
+       struct rval_expr* r_rve = NULL;
        int i;
        int ret;
        enum rval_expr_op op;
@@ -3124,7 +3125,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
                        pos=(e)->fpos; \
                        *(e)=*(v); /* replace e with v (in-place) */ \
                        (e)->fpos=pos; \
-                       pkg_free((v)); /* rve_destroy(v_rve) would free everything*/ \
+                       r_rve = v; /* link to free it */ \
                }else{\
                        /* unknown type or str => (int) $v */ \
                        (e)->op=RVE_##ctype##_OP; \
@@ -3480,9 +3481,11 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type)
                }
        }
        if (rv) rval_destroy(rv);
+       if (r_rve) pkg_free(r_rve); /* rve_destroy(v_rve) would free everything*/
        return ret;
 error:
        if (rv) rval_destroy(rv);
+       if (r_rve) pkg_free(r_rve); /* rve_destroy(v_rve) would free everything*/
        return -1;
 }