[sr-dev] git:master:f401938a: acc: free parameter in acc fixup in case of error

Daniel-Constantin Mierla miconda at gmail.com
Sat Jul 8 09:48:49 CEST 2017


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-08T09:48:35+02:00

acc: free parameter in acc fixup in case of error

---

Modified: src/modules/acc/acc_logic.c
Modified: src/modules/acc/acc_mod.c

---

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

---

diff --git a/src/modules/acc/acc_logic.c b/src/modules/acc/acc_logic.c
index 02de9f4cf3..bb3b05b5cb 100644
--- a/src/modules/acc/acc_logic.c
+++ b/src/modules/acc/acc_logic.c
@@ -391,26 +391,26 @@ static inline int should_acc_reply(struct sip_msg *req, struct sip_msg *rpl,
 {
     unsigned int i;
 
-	/* negative transactions reported otherwise only if explicitly 
+	/* negative transactions reported otherwise only if explicitly
 	 * demanded */
 
     if (code >= 300) {
-	if (!is_failed_acc_on(req)) return 0;
-	i = 0;
-	while (failed_filter[i] != 0) {
-	    if (failed_filter[i] == code) return 0;
-	    i++;
-	}
-	return 1;
+		if (!is_failed_acc_on(req)) return 0;
+		i = 0;
+		while (failed_filter[i] != 0) {
+		    if (failed_filter[i] == code) return 0;
+		    i++;
+		}
+		return 1;
     }
 
     if ( !is_acc_on(req) )
-	return 0;
-	
+		return 0;
+
     if ( code<200 && !(early_media &&
 		       parse_headers(rpl,HDR_CONTENTLENGTH_F, 0) == 0 &&
 		       rpl->content_length && get_content_length(rpl) > 0))
-	return 0;
+		return 0;
 
     return 1; /* seed is through, we will account this reply */
 }
@@ -424,8 +424,10 @@ static inline void acc_onreply_in(struct cell *t, struct sip_msg *req,
 	/* don't parse replies in which we are not interested */
 	/* missed calls enabled ? */
 	if ( (reply && reply!=FAKED_REPLY) && (should_acc_reply(req,reply,code)
-	|| (is_invite(t) && code>=300 && is_mc_on(req))) ) {
-		parse_headers(reply, HDR_TO_F, 0 );
+			|| (is_invite(t) && code>=300 && is_mc_on(req))) ) {
+		if(parse_headers(reply, HDR_TO_F, 0)<0) {
+			LM_ERR("failed to parse headers\n");
+		}
 	}
 }
 
@@ -463,7 +465,7 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
 
 	/* we report on missed calls when the first
 	 * forwarding attempt fails; we do not wish to
-	 * report on every attempt; so we clear the flags; 
+	 * report on every attempt; so we clear the flags;
 	 */
 
 	if (is_log_mc_on(req)) {
@@ -684,4 +686,4 @@ static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps )
 	} else if (type&TMCB_RESPONSE_IN) {
 		acc_onreply_in( t, ps->req, ps->rpl, ps->code);
 	}
-}
\ No newline at end of file
+}
diff --git a/src/modules/acc/acc_mod.c b/src/modules/acc/acc_mod.c
index 6665446843..f0582b2315 100644
--- a/src/modules/acc/acc_mod.c
+++ b/src/modules/acc/acc_mod.c
@@ -313,16 +313,17 @@ static int acc_fixup(void** param, int param_no)
 		if (strchr(p,PV_MARKER)!=NULL) { /* is a variable $xxxxx */
 			if (pv_parse_format(&accp->reason, &accp->elem)<0)
 			{
-				LM_ERR("bad param 1; "
-					"parse format error [%.*s]\n", accp->reason.len, accp->reason.s);
+				LM_ERR("bad param 1 - parse format error [%.*s]\n",
+						accp->reason.len, accp->reason.s);
+				pkg_free(accp);
 				return E_UNSPEC;
 			}
 		}
 		else {
 			if(acc_parse_code(p,accp)<0)
 			{
-				LM_ERR("bad param 1;"
-					"parse code error\n");
+				LM_ERR("bad param 1 - parse code error\n");
+				pkg_free(accp);
 				return E_UNSPEC;
 			}
 		}
@@ -810,4 +811,4 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
 {
 	sr_kemi_modules_add(sr_kemi_acc_exports);
 	return 0;
-}
\ No newline at end of file
+}




More information about the sr-dev mailing list