res_pjsip_session: Check for removed stream state.

When a sip session is refreshed, the stream topology is looped
through, checking each stream for compatible formats. This would
cause a crash if the stream state was AST_STREAM_STATE_REMOVED,
since the formats would never be set for this stream, causing
a NULL value to be returned from ast_stream_get_formats. This
commit adds a check for streams with removed states.

Also removed a stray semicolon.

Change-Id: Ic86f8b65a4a26a60885b28b8b1a0b22e1b471d42
This commit is contained in:
Ben Ford
2017-09-15 09:43:21 -05:00
committed by Benjamin Keith Ford
parent 8830cc0541
commit e666051d79
3 changed files with 8 additions and 6 deletions

View File

@@ -1455,6 +1455,10 @@ int ast_sip_session_refresh(struct ast_sip_session *session,
continue;
}
/* No need to do anything with stream if it's media state is removed */
if (ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED) {
continue;
}
/* Enforce the configured allowed codecs on audio and video streams */
if (ast_stream_get_type(stream) == AST_MEDIA_TYPE_AUDIO || ast_stream_get_type(stream) == AST_MEDIA_TYPE_VIDEO) {
@@ -1465,14 +1469,12 @@ int ast_sip_session_refresh(struct ast_sip_session *session,
ast_sip_session_media_state_free(media_state);
return 0;
}
ast_format_cap_get_compatible(ast_stream_get_formats(stream), session->endpoint->media.codecs, joint_cap);
if (!ast_format_cap_count(joint_cap)) {
ao2_ref(joint_cap, -1);
ast_sip_session_media_state_free(media_state);
return 0;
ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);
continue;
}
ast_stream_set_formats(stream, joint_cap);
}