]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
pjsip: avoid possible crash req_caps allocation failure 15/1215/3
authorScott Griepentrog <scott@griepentrog.com>
Tue, 8 Sep 2015 15:35:57 +0000 (10:35 -0500)
committerScott Griepentrog <sgriepentrog@digium.com>
Wed, 9 Sep 2015 18:13:23 +0000 (13:13 -0500)
Make certain that the pjsip session has not failed to
allocate the format capabilities structure, which can
otherwise cause a crash when referenced.

ASTERISK-25323

Change-Id: I602790ba12714741165e441cc64a3ecde4cb5750

res/res_pjsip_session.c

index 16ed38dd06ec2ec69a4aa6f5e1bd633c47447838..6044ceb7fa48de2a2b7b3e69453d41d8b718b05d 100644 (file)
@@ -1297,6 +1297,11 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint,
        session->contact = ao2_bump(contact);
        session->inv_session = inv_session;
        session->req_caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+       if (!session->req_caps) {
+               /* Release the ref held by session->inv_session */
+               ao2_ref(session, -1);
+               return NULL;
+       }
 
        if ((endpoint->dtmf == AST_SIP_DTMF_INBAND) || (endpoint->dtmf == AST_SIP_DTMF_AUTO)) {
                dsp_features |= DSP_FEATURE_DIGIT_DETECT;