[sr-dev] git:master:021e49d6: tm: refactored error handling for eval_uac_routing()

Daniel-Constantin Mierla miconda at gmail.com
Mon Jul 24 08:27:48 CEST 2017


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-23T10:08:47+02:00

tm: refactored error handling for eval_uac_routing()

---

Modified: src/modules/tm/t_msgbuilder.c

---

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

---

diff --git a/src/modules/tm/t_msgbuilder.c b/src/modules/tm/t_msgbuilder.c
index 3bd76b32fe..c4ab254076 100644
--- a/src/modules/tm/t_msgbuilder.c
+++ b/src/modules/tm/t_msgbuilder.c
@@ -912,7 +912,6 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct retr_buf *inv_rb,
 	int is_req;
 	struct sip_uri puri;
 	static size_t chklen;
-	int ret = -1;
 
 	/* parse the retr. buffer */
 	memset(&orig_inv, 0, sizeof(struct sip_msg));
@@ -931,14 +930,14 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct retr_buf *inv_rb,
 		/* the bug is at message assembly */
 		LM_BUG("failed to parse INVITE retr. buffer and/or extract 'To' HF:"
 				"\n%.*s\n", (int)orig_inv.len, orig_inv.buf);
-		goto end;
+		goto error;
 	}
 	if (((struct to_body *)orig_inv.to->parsed)->tag_value.len) {
 		LM_DBG("building ACK for in-dialog INVITE (using RS in orig. INV.)\n");
 		if (parse_headers(&orig_inv, HDR_EOH_F, 0) < 0) {
 			LM_BUG("failed to parse INVITE retr. buffer to EOH:"
 					"\n%.*s\n", (int)orig_inv.len, orig_inv.buf);
-			goto end;
+			goto error;
 		}
 		sipmsg = &orig_inv;
 		is_req = 1;
@@ -951,7 +950,7 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct retr_buf *inv_rb,
 	/* extract the route set */
 	if (get_uac_rs(sipmsg, is_req, &rtset) < 0) {
 		LM_ERR("failed to extract route set.\n");
-		goto end;
+		goto error;
 	}
 
 	if (! rtset) { /* No routes */
@@ -961,7 +960,7 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct retr_buf *inv_rb,
 		if (parse_uri(rtset->ptr->nameaddr.uri.s, rtset->ptr->nameaddr.uri.len,
 				&puri) < 0) {
 			LM_ERR("failed to parse first route in set.\n");
-			goto end;
+			goto error;
 		}
 
 		if (puri.lr.s) { /* Next hop is loose router */
@@ -993,7 +992,7 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct retr_buf *inv_rb,
 			} else {
 				LM_ERR("failed to establish what kind of router the next "
 						"hop is.\n");
-				goto end;
+				goto error;
 			}
 			break;
 		case F_RB_NH_LOOSE:
@@ -1028,8 +1027,7 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct retr_buf *inv_rb,
 					} else {
 						prev_t->next = NULL;
 					}
-					ret = -1;
-					goto end;
+					goto error;
 				}
 				/* this way, .free_rr is also set to 0 (!!!) */
 				memset(t, 0, chklen);
@@ -1054,19 +1052,21 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct retr_buf *inv_rb,
 #ifdef EXTRA_DEBUG
 			abort();
 #else
-			goto end;
+			goto error;
 #endif
 		}
 	}
 
 	*list = rtset;
+	free_sip_msg(&orig_inv);
 	/* all went well */
-	ret = 0;
-end:
+	return 0;
+
+error:
 	free_sip_msg(&orig_inv);
-	if (ret < 0)
+	if (rtset)
 		free_rte_list(rtset);
-	return ret;
+	return -1;
 }
 
 /*




More information about the sr-dev mailing list