diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index 10c5f293b1eb1a8e2e3ddc58918b3dcf2a5ab76e..76d37f2b3be46afac9715b84a4bd9e1582292269 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -91,10 +91,13 @@ static enum pjsip_status_code check_content_type_in_dialog(const pjsip_rx_data *
 	static const pj_str_t text = { "text", 4};
 	static const pj_str_t application = { "application", 11};
 
+	if (!(rdata->msg_info.msg->body && rdata->msg_info.msg->body->len > 0)) {
+		return res;
+	}
+
 	/* We'll accept any text/ or application/ content type */
-	if (rdata->msg_info.msg->body && rdata->msg_info.msg->body->len
-		&& (pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0
-			|| pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &application) == 0)) {
+	if (pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0
+			|| pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &application) == 0) {
 		res = PJSIP_SC_OK;
 	} else if (rdata->msg_info.ctype
 		&& (pj_stricmp(&rdata->msg_info.ctype->media.type, &text) == 0