[sr-dev] git:master:7652f796: core: rvalue - link to free at end of rve_opt_01() instead on replace

Daniel-Constantin Mierla miconda at gmail.com
Tue Apr 6 17:44:13 CEST 2021


Module: kamailio
Branch: master
Commit: 7652f79640b3e792baa77531e697fd74a1ab4584
URL: https://github.com/kamailio/kamailio/commit/7652f79640b3e792baa77531e697fd74a1ab4584

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-04-06T17:23:16+02:00

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

- debug mode messages print fields

---

Modified: src/core/rvalue.c

---

Diff:  https://github.com/kamailio/kamailio/commit/7652f79640b3e792baa77531e697fd74a1ab4584.diff
Patch: https://github.com/kamailio/kamailio/commit/7652f79640b3e792baa77531e697fd74a1ab4584.patch

---

diff --git a/src/core/rvalue.c b/src/core/rvalue.c
index f96f8ea536..902f3c2c66 100644
--- a/src/core/rvalue.c
+++ b/src/core/rvalue.c
@@ -3185,6 +3185,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;
@@ -3208,7 +3209,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; \
@@ -3564,9 +3565,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;
 }
 




More information about the sr-dev mailing list