From 5f73fec33a2e1bf5b4b58b69beeb4ddf9eb5c42c Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 25 Sep 2024 07:05:01 -0400 Subject: [PATCH] MT#55283 ice streams: fix Coverity Scan defect Fixes: *** CID 1599964: (FORWARD_NULL) /daemon/ice.c: 109 in ice_update_media_streams() 103 104 105 static void ice_update_media_streams(struct call_monologue *ml, sdp_streams_q *streams, sdp_sessions_q *sdp, 106 sdp_ng_flags *flags) 107 { 108 if (!streams || !streams->head) { >>> CID 1599964: (FORWARD_NULL) >>> Passing null pointer "streams" to "sdp_streams", which dereferences it. 109 if (sdp_streams(sdp, streams, flags)) { 110 ilogs(ice, LOG_WARN, "Incomplete SDP specification for tricle ICE"); 111 return; 112 } 113 } 114 /daemon/ice.c: 115 in ice_update_media_streams() 109 if (sdp_streams(sdp, streams, flags)) { 110 ilogs(ice, LOG_WARN, "Incomplete SDP specification for tricle ICE"); 111 return; 112 } 113 } 114 >>> CID 1599964: (FORWARD_NULL) >>> Dereferencing null pointer "streams". 115 for (__auto_type l = streams->head; l; l = l->next) { 116 struct stream_params *sp = l->data; 117 struct call_media *media = NULL; 118 119 if (sp->media_id.len) 120 media = g_hash_table_lookup(ml->media_ids, &sp->media_id); Change-Id: Ic58c9c423ee17e08b42027bc68ba33f94913fd03 --- daemon/ice.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/ice.c b/daemon/ice.c index 4b672c104..34739c98b 100644 --- a/daemon/ice.c +++ b/daemon/ice.c @@ -105,7 +105,12 @@ static fragments_ht sdp_fragments; static void ice_update_media_streams(struct call_monologue *ml, sdp_streams_q *streams, sdp_sessions_q *sdp, sdp_ng_flags *flags) { - if (!streams || !streams->head) { + g_auto(sdp_streams_q) streams_local = TYPED_GQUEUE_INIT; + + if (!streams) + streams = &streams_local; + + if (!streams->head) { if (sdp_streams(sdp, streams, flags)) { ilogs(ice, LOG_WARN, "Incomplete SDP specification for tricle ICE"); return;