From da134849e86de1d2325516301ceae948431cbab0 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Mon, 13 Nov 2023 10:04:33 +0100 Subject: [PATCH] MT#57719 Fix defect spotted by Coverity Scan (85fc7ff) *** CID 1570963: Null pointer dereferences (REVERSE_INULL) /daemon/call.c: 3553 in monologue_subscribe_answer() 3547 /* set src_media based on subscription (assuming it is one-to-one) */ 3548 struct call_media * dst_media = __get_media(dst_ml, sp, flags, 0); 3549 GList * src_ml_media_it = dst_media->media_subscriptions.head; 3550 struct media_subscription * ms = src_ml_media_it->data; 3551 struct call_media * src_media = ms->media; 3552 >>> CID 1570963: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "dst_media" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 3553 if (!dst_media || !src_media) 3554 continue; 3555 3556 /* additional attributes to be carried for `sdp_create()` */ 3557 if (print_extra_sess_attrs && !g_queue_find(&attr_mls, ms->monologue)) { 3558 sdp_copy_session_attributes(ms->monologue, dst_ml); Change-Id: I391b95f61237e5a7af206b0568a1cf421dcbb8f8 --- daemon/call.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 1c5d99cfcd..89a326043a 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -3413,16 +3413,19 @@ int monologue_subscribe_answer(struct call_monologue *dst_ml, struct sdp_ng_flag for (GList * l = streams->head; l; l = l->next) { struct stream_params * sp = l->data; + struct call_media * dst_media = __get_media(dst_ml, sp, flags, 0); + + if (!dst_media) + continue; /* set src_media based on subscription (assuming it is one-to-one) * TODO: this should probably be reworked to support one-to-multi subscriptions. */ - struct call_media * dst_media = __get_media(dst_ml, sp, flags, 0); GList * src_ml_media_it = dst_media->media_subscriptions.head; struct media_subscription * ms = src_ml_media_it->data; struct call_media * src_media = ms->media; - if (!dst_media || !src_media) + if (!src_media) continue; /* additional attributes to be carried for `sdp_create()` */