From 78191d9216f61ef5e6fff6ea147309b935aae322 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 25 Dec 2024 09:05:34 -0400 Subject: [PATCH] MT#61368 improve media finding logic Avoids a potential null dereference as well Change-Id: I177f6f6e11b2c24ff49a8fca88121513f764dbe4 Warned-by: Coverity --- daemon/call.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 378c2eecb..e0b26253a 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -3062,19 +3062,17 @@ int monologue_offer_answer(struct call_monologue *monologues[2], sdp_streams_q * for (auto_iter(l, sender_media->media_subscriptions.head); l && !receiver_media; l = l->next) { __auto_type ms = l->data; __auto_type r_media = ms->media; + if (!r_media) + continue; if (r_media->monologue != receiver_ml) continue; - if (r_media) { - // check type, it must match - if (str_cmp_str(&r_media->type, &sender_media->type)) - continue; - } - if (r_media) { - // check a=mid, it must match if present - if (sender_media->media_id.len && r_media->media_id.len - && str_cmp_str(&sender_media->media_id, &r_media->media_id)) - continue; - } + // check type, it must match + if (str_cmp_str(&r_media->type, &sender_media->type)) + continue; + // check a=mid, it must match if present + if (sender_media->media_id.len && r_media->media_id.len + && str_cmp_str(&sender_media->media_id, &r_media->media_id)) + continue; // found it receiver_media = r_media; }