Browse code

Merge d161d4523fc6b0619defe918bc204cc7a9cae073 into 432c7dd30976d1e4be9db35de39d67cc0e1a5e95

Alex Hermann authored on 23/10/2020 07:36:47 • GitHub committed on 23/10/2020 07:36:47
Showing 1 changed files
... ...
@@ -805,14 +805,24 @@ int pv_get_t_branch(struct sip_msg *msg,  pv_param_t *param,
805 805
 								" in MODE_ONFAILURE\n", branch);
806 806
 						return pv_get_null(msg, param, res);
807 807
 					}
808
-					res->ri = t->uac[branch].branch_flags;
809
-					res->flags = PV_VAL_INT;
810
-					LM_DBG("branch flags is [%u]\n", res->ri);
808
+					break;
809
+				case TM_ONREPLY_ROUTE:
810
+					tcx = _tmx_tmb.tm_ctx_get();
811
+					if(tcx == NULL) {
812
+						LM_ERR("no reply branch\n");
813
+						return pv_get_null(msg, param, res);
814
+					}
815
+					branch = tcx->branch_index;
811 816
 					break;
812 817
 				default:
813 818
 					LM_ERR("unsupported route_type %d\n", get_route_type());
814 819
 					return pv_get_null(msg, param, res);
815 820
 			}
821
+			if(branch<0 || branch>=t->nr_of_outgoings) {
822
+				return pv_get_null(msg, param, res);
823
+			}
824
+			LM_DBG("branch flags is [%u]\n", t->uac[branch].branch_flags);
825
+			return pv_get_uintval(msg, param, res, t->uac[branch].branch_flags);
816 826
 			break;
817 827
 		case 6: /* $T_branch(uri) */
818 828
 			if (get_route_type() != TM_ONREPLY_ROUTE) {