Ticket #620: PRACK is sent to the wrong UAS when 100rel is used and the dialog forks (thanks Ruud Klaver for the report)
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2271 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsip-ua/sip_100rel.c b/pjsip/src/pjsip-ua/sip_100rel.c
index 657b298..d8bb402 100644
--- a/pjsip/src/pjsip-ua/sip_100rel.c
+++ b/pjsip/src/pjsip-ua/sip_100rel.c
@@ -417,14 +417,26 @@
pj_str_t method;
pj_status_t status;
- dd = (dlg_data*) inv->dlg->mod_data[mod_100rel.mod.id];
- PJ_ASSERT_RETURN(dd != NULL, PJSIP_ENOTINITIALIZED);
-
tsx = pjsip_rdata_get_tsx(rdata);
pj_assert(tsx != NULL);
msg = rdata->msg_info.msg;
+ dd = (dlg_data*) inv->dlg->mod_data[mod_100rel.mod.id];
+ if (dd == NULL) {
+ /* UAC sends us PRACK while we didn't send reliable provisional
+ * response. Respond with 400 (?)
+ */
+ const pj_str_t reason = pj_str("Unexpected PRACK");
+
+ status = pjsip_dlg_create_response(inv->dlg, rdata, 400,
+ &reason, &tdata);
+ if (status == PJ_SUCCESS) {
+ status = pjsip_dlg_send_response(inv->dlg, tsx, tdata);
+ }
+ return PJSIP_ENOTINITIALIZED;
+ }
+
/* Always reply with 200/OK for PRACK */
status = pjsip_dlg_create_response(inv->dlg, rdata, 200, NULL, &tdata);
if (status == PJ_SUCCESS) {