[Asterisk-code-review] res_pjsip_session: Make reschedule_reinvite check for NULL topologies (asterisk[master])
George Joseph
asteriskteam at digium.com
Fri Mar 19 12:59:59 CDT 2021
George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15655 )
Change subject: res_pjsip_session: Make reschedule_reinvite check for NULL topologies
......................................................................
res_pjsip_session: Make reschedule_reinvite check for NULL topologies
When the check for equal topologies was added to reschedule_reinvite()
it was assumed that both the pending and active media states would
actually have non-NULL topologies. We since discovered this isn't
the case.
We now only test for euql topologies if both media states have
non-NULL topologies. The logic had to be rearranged a bit to make
sure that we cloned the media states if their topologies were
non-NULL but weren't equal.
ASTERISK-29215
Change-Id: I61313cca7fc571144338aac826091791b87b6e17
---
M res/res_pjsip_session.c
1 file changed, 25 insertions(+), 3 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/55/15655/1
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index e319842..3f61b63 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -4273,18 +4273,40 @@
struct ast_sip_session_media_state *pending_media_state = NULL;
struct ast_sip_session_media_state *active_media_state = NULL;
const char *session_name = ast_sip_session_get_name(session);
+ int use_pending = 0;
+ int use_active = 0;
+
SCOPE_ENTER(3, "%s\n", session_name);
- /* If the two media state topologies are the same this means that the session refresh request
+ /*
+ * If the two media state topologies are the same this means that the session refresh request
* did not specify a desired topology, so it does not care. If that is the case we don't even
- * pass one in here resulting in the current topology being used.
+ * pass one in here resulting in the current topology being used. It's possible though that
+ * either one of the topologies could be NULL so we have to test for that before we check for
+ * equality.
*/
- if (!ast_stream_topology_equal(session->active_media_state->topology, session->pending_media_state->topology)) {
+
+ /* We only want to clone a media state if its topology is not null */
+ use_pending = session->pending_media_state->topology != NULL;
+ use_active = session->active_media_state->topology != NULL;
+
+ /*
+ * If both media states have topologies, we can test for equality. If they're equal we're not going to
+ * clone either states.
+ */
+ if (use_pending && use_active && ast_stream_topology_equal(session->active_media_state->topology, session->pending_media_state->topology)) {
+ use_pending = 0;
+ use_active = 0;
+ }
+
+ if (use_pending) {
pending_media_state = ast_sip_session_media_state_clone(session->pending_media_state);
if (!pending_media_state) {
SCOPE_EXIT_LOG_RTN(LOG_ERROR, "%s: Failed to clone pending media state\n", session_name);
}
+ }
+ if (use_active) {
active_media_state = ast_sip_session_media_state_clone(session->active_media_state);
if (!active_media_state) {
ast_sip_session_media_state_free(pending_media_state);
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15655
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I61313cca7fc571144338aac826091791b87b6e17
Gerrit-Change-Number: 15655
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210319/5ad63f8c/attachment.html>
More information about the asterisk-code-review
mailing list