From ecb6949ce990a0ddf2a2e73a7113baae5253143c Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 2 Feb 2006 21:14:29 +0000 Subject: Added more asserts git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@130 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip/sip_transaction.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c index 39bc8d20..cf07ddf0 100644 --- a/pjsip/src/pjsip/sip_transaction.c +++ b/pjsip/src/pjsip/sip_transaction.c @@ -974,7 +974,14 @@ PJ_DEF(pj_status_t) pjsip_tsx_create_uac( pjsip_module *tsx_user, struct tsx_lock_data lck; pj_status_t status; - PJ_ASSERT_RETURN(tdata!=NULL && p_tsx!=NULL, PJ_EINVAL); + /* Validate arguments. */ + PJ_ASSERT_RETURN(tdata && tdata->msg && p_tsx, PJ_EINVAL); + PJ_ASSERT_RETURN(tdata->msg->type == PJSIP_REQUEST_MSG, + PJSIP_ENOTREQUESTMSG); + + /* Method MUST NOT be ACK! */ + PJ_ASSERT_RETURN(tdata->msg->line.req.method.id != PJSIP_ACK_METHOD, + PJ_EINVALIDOP); /* Keep shortcut */ msg = tdata->msg; @@ -1097,7 +1104,8 @@ PJ_DEF(pj_status_t) pjsip_tsx_create_uas( pjsip_module *tsx_user, pj_status_t status; struct tsx_lock_data lck; - PJ_ASSERT_RETURN(rdata!=NULL && p_tsx!=NULL, PJ_EINVAL); + /* Validate arguments. */ + PJ_ASSERT_RETURN(rdata && rdata->msg_info.msg && p_tsx, PJ_EINVAL); /* Keep shortcut to message */ msg = rdata->msg_info.msg; @@ -1105,6 +1113,10 @@ PJ_DEF(pj_status_t) pjsip_tsx_create_uas( pjsip_module *tsx_user, /* Make sure this is a request message. */ PJ_ASSERT_RETURN(msg->type == PJSIP_REQUEST_MSG, PJSIP_ENOTREQUESTMSG); + /* Make sure method is not ACK */ + PJ_ASSERT_RETURN(msg->line.req.method.id != PJSIP_ACK_METHOD, + PJ_EINVALIDOP); + /* Make sure CSeq header is present. */ cseq = rdata->msg_info.cseq; if (!cseq) -- cgit v1.2.3