Fixed crash in SRTP when incoming SDP is received without any m= line (thanks Atik)

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1909 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 4035011..5833098 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -716,13 +716,27 @@
 				   rdata->msg_info.msg->body->data,
 				   rdata->msg_info.msg->body->len, &offer);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror(THIS_FILE, "Error parsing SDP in incoming INVITE", status);
-	    pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 400, NULL,
+	    const pj_str_t reason = pj_str("Bad SDP");
+	    pjsua_perror(THIS_FILE, "Error parsing SDP in incoming INVITE", 
+			 status);
+	    pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 400, &reason,
 					  NULL, NULL);
 	    pjsua_media_channel_deinit(call->index);
 	    PJSUA_UNLOCK();
 	    return PJ_TRUE;
 	}
+
+	/* Do quick checks on SDP before passing it to transports. More elabore 
+	 * checks will be done in pjsip_inv_verify_request2() below.
+	 */
+	if (offer->media_count==0) {
+	    const pj_str_t reason = pj_str("Missing media in SDP");
+	    pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, &reason, 
+				NULL, NULL, NULL);
+	    PJSUA_UNLOCK();
+	    return PJ_TRUE;
+	}
+
     } else {
 	offer = NULL;
     }