Ticket #623: Assertion when receiving SUBSCRIBE with non presence event (thanks Lucas Rosa Galêgo for the report)

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2273 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index f0a2100..0e3cc21 100644
--- a/pjsip/src/pjsua-lib/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -718,9 +718,22 @@
     /* Create server presence subscription: */
     status = pjsip_pres_create_uas( dlg, &pres_cb, rdata, &sub);
     if (status != PJ_SUCCESS) {
-	pjsip_dlg_terminate(dlg);
+	int code = PJSIP_ERRNO_TO_SIP_STATUS(status);
+	pjsip_tx_data *tdata;
+
 	pjsua_perror(THIS_FILE, "Unable to create server subscription", 
 		     status);
+
+	if (code==599 || code > 699 || code < 300) {
+	    code = 400;
+	}
+
+	status = pjsip_dlg_create_response(dlg, rdata, code, NULL, &tdata);
+	if (status == PJ_SUCCESS) {
+	    status = pjsip_dlg_send_response(dlg, pjsip_rdata_get_tsx(rdata),
+					     tdata);
+	}
+
 	PJSUA_UNLOCK();
 	return PJ_TRUE;
     }