[sr-dev] git:master:2d771f56: htable: release pkg memory before returning

lazedo luis.azedo at factorlusitano.com
Fri Jun 2 15:20:16 CEST 2017


Module: kamailio
Branch: master
Commit: 2d771f563d19fccad0a28e56a5d99de571ef5da6
URL: https://github.com/kamailio/kamailio/commit/2d771f563d19fccad0a28e56a5d99de571ef5da6

Author: lazedo <luis.azedo at factorlusitano.com>
Committer: lazedo <luis.azedo at factorlusitano.com>
Date: 2017-06-02T14:20:12+01:00

htable: release pkg memory before returning

resets 'first' when esize == 0

---

Modified: src/modules/htable/ht_var.c

---

Diff:  https://github.com/kamailio/kamailio/commit/2d771f563d19fccad0a28e56a5d99de571ef5da6.diff
Patch: https://github.com/kamailio/kamailio/commit/2d771f563d19fccad0a28e56a5d99de571ef5da6.patch

---

diff --git a/src/modules/htable/ht_var.c b/src/modules/htable/ht_var.c
index 36cceb4fb9..522811da58 100644
--- a/src/modules/htable/ht_var.c
+++ b/src/modules/htable/ht_var.c
@@ -48,17 +48,17 @@ int pv_get_ht_cell(struct sip_msg *msg,  pv_param_t *param,
 		return -1;
 	}
 	htc = ht_cell_pkg_copy(hpv->ht, &htname, _htc_local);
+	if(_htc_local!=htc)
+	{
+		ht_cell_pkg_free(_htc_local);
+		_htc_local=htc;
+	}
 	if(htc==NULL)
 	{
 		if(hpv->ht->flags==PV_VAL_INT)
 			return pv_get_sintval(msg, param, res, hpv->ht->initval.n);
 		return pv_get_null(msg, param, res);
 	}
-	if(_htc_local!=htc)
-	{
-		ht_cell_pkg_free(_htc_local);
-		_htc_local=htc;
-	}
 
 	if(htc->flags&AVP_VAL_STR)
 		return pv_get_strval(msg, param, res, &htc->value.s);
@@ -326,15 +326,15 @@ int pv_get_ht_add(struct sip_msg *msg,  pv_param_t *param,
 		return -1;
 	}
 	htc = ht_cell_value_add(hpv->ht, &htname, val, 1, _htc_local);
-	if(htc==NULL)
-	{
-		return pv_get_null(msg, param, res);
-	}
 	if(_htc_local!=htc)
 	{
 		ht_cell_pkg_free(_htc_local);
 		_htc_local=htc;
 	}
+	if(htc==NULL)
+	{
+		return pv_get_null(msg, param, res);
+	}
 
 	if(htc->flags&AVP_VAL_STR)
 		return pv_get_null(msg, param, res);




More information about the sr-dev mailing list