Browse code

Merge ed12500804ccdbf4f9428e1fc8c1fcfe58217f6e into 0e806316b84be8388dad670e964e54011000b4a4

Julien Chavanton authored on 04/06/2021 23:58:21 • GitHub committed on 04/06/2021 23:58:21
Showing 1 changed files
... ...
@@ -118,18 +118,23 @@ int t_suspend(struct sip_msg *msg,
118 118
 			LM_ERR("failed find UAC branch\n");
119 119
 			return -1;
120 120
 		}
121
-		LM_DBG("found a a match with branch id [%d] - "
122
-				"cloning reply message to t->uac[branch].reply\n", branch);
123 121
 
124
-		sip_msg_len = 0;
125
-		t->uac[branch].reply = sip_msg_cloner( msg, &sip_msg_len );
122
+		if (!t->uac[branch].reply) {
123
+			sip_msg_len = 0;
124
+			LM_DBG("found a match with branch id [%d] - "
125
+				"cloning reply message to t->uac[branch].reply\n", branch);
126
+			t->uac[branch].reply = sip_msg_cloner( msg, &sip_msg_len );
126 127
 
127
-		if (! t->uac[branch].reply ) {
128
-			LM_ERR("can't alloc' clone memory\n");
129
-			return -1;
128
+			if (! t->uac[branch].reply ) {
129
+				LM_ERR("can't alloc' clone memory\n");
130
+				return -1;
131
+			}
132
+			t->uac[branch].end_reply = ((char*)t->uac[branch].reply) + sip_msg_len;
133
+		} else {
134
+			LM_DBG("found a match with branch id [%d] - "
135
+				"message already cloned to t->uac[branch].reply\n", branch);
136
+			// This can happen when suspending more than once in a reply.
130 137
 		}
131
-		t->uac[branch].end_reply = ((char*)t->uac[branch].reply) + sip_msg_len;
132
-
133 138
 		LM_DBG("saving transaction data\n");
134 139
 		t->uac[branch].reply->flags = msg->flags;
135 140
 		t->flags |= T_ASYNC_SUSPENDED;