]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Add missing NULL checks when using pjsip_inv_end_session(). 26/3126/1
authorRichard Mudgett <rmudgett@digium.com>
Wed, 22 Jun 2016 23:02:59 +0000 (18:02 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Thu, 30 Jun 2016 17:09:10 +0000 (12:09 -0500)
pjsip_inv_end_session() is documented as being able to return the
passed in tdata parameter set to NULL on success.

Change-Id: I09d53725c49b7183c41bfa1be3ff225f3a8d3047

channels/chan_pjsip.c
res/res_pjsip_refer.c
res/res_pjsip_session.c

index 970fef496a597a8373e63613a5acffb03d051888..bbccb53a99bc9275046afaabca6f30f9aadad2cb 100644 (file)
@@ -1417,7 +1417,8 @@ static void transfer_redirect(struct ast_sip_session *session, const char *targe
        pjsip_contact_hdr *contact;
        pj_str_t tmp;
 
-       if (pjsip_inv_end_session(session->inv_session, 302, NULL, &packet) != PJ_SUCCESS) {
+       if (pjsip_inv_end_session(session->inv_session, 302, NULL, &packet) != PJ_SUCCESS
+               || !packet) {
                ast_log(LOG_WARNING, "Failed to redirect PJSIP session for channel %s\n",
                        ast_channel_name(session->channel));
                message = AST_TRANSFER_FAILED;
@@ -2182,7 +2183,8 @@ static int chan_pjsip_incoming_request(struct ast_sip_session *session, struct p
        ast_sip_session_add_datastore(session, datastore);
 
        if (!(session->channel = chan_pjsip_new(session, AST_STATE_RING, session->exten, NULL, NULL, NULL, NULL))) {
-               if (pjsip_inv_end_session(session->inv_session, 503, NULL, &packet) == PJ_SUCCESS) {
+               if (pjsip_inv_end_session(session->inv_session, 503, NULL, &packet) == PJ_SUCCESS
+                       && packet) {
                        ast_sip_session_send_response(session, packet);
                }
 
index f3af65c3cf304f0474ef0dfe1fa975bbf27acfd2..e5bb90e5c0cafa0a7ff87171da9f9910d85db55c 100644 (file)
@@ -969,7 +969,8 @@ inv_replace_failed:
                session->defer_terminate = 1;
                ast_hangup(session->channel);
 
-               if (pjsip_inv_end_session(session->inv_session, response, NULL, &packet) == PJ_SUCCESS) {
+               if (pjsip_inv_end_session(session->inv_session, response, NULL, &packet) == PJ_SUCCESS
+                       && packet) {
                        ast_sip_session_send_response(session, packet);
                }
        } else {
index 23d2f2f2a956f4bb4d876b9401f2664f74c582d9..5bbd0c01bbd810fe84dd6e38fc94e3fc012a99bb 100644 (file)
@@ -2619,7 +2619,8 @@ static void session_inv_on_tsx_state_changed(pjsip_inv_session *inv, pjsip_trans
                                                }
                                                if (tsx->status_code != 488) {
                                                        /* Other reinvite failures (except 488) result in destroying the session. */
-                                                       if (pjsip_inv_end_session(inv, 500, NULL, &tdata) == PJ_SUCCESS) {
+                                                       if (pjsip_inv_end_session(inv, 500, NULL, &tdata) == PJ_SUCCESS
+                                                               && tdata) {
                                                                ast_sip_session_send_request(session, tdata);
                                                        }
                                                }
@@ -2632,7 +2633,8 @@ static void session_inv_on_tsx_state_changed(pjsip_inv_session *inv, pjsip_trans
                                                 * a cancelled call. Our role is to immediately send a BYE to end the
                                                 * dialog.
                                                 */
-                                               if (pjsip_inv_end_session(inv, 500, NULL, &tdata) == PJ_SUCCESS) {
+                                               if (pjsip_inv_end_session(inv, 500, NULL, &tdata) == PJ_SUCCESS
+                                                       && tdata) {
                                                        ast_sip_session_send_request(session, tdata);
                                                }
                                        }