diff options
author | Scott Griepentrog <scott@griepentrog.com> | 2015-09-08 10:35:57 -0500 |
---|---|---|
committer | Scott Griepentrog <sgriepentrog@digium.com> | 2015-09-09 13:13:23 -0500 |
commit | f72f9ceefca52002c45f5910219dbcb0f9437a79 (patch) | |
tree | fdd05477796d17ba4bc294a80e7741e9b272a88a | |
parent | 34ad877bac16e70bf6c6ac8d881716e6b25f5b07 (diff) |
pjsip: avoid possible crash req_caps allocation failure
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
-rw-r--r-- | res/res_pjsip_session.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index 16ed38dd0..6044ceb7f 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -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; |