From f636f54a2ff6302a1f987c1a2de43f802c78db4c Mon Sep 17 00:00:00 2001 From: Donat Zenichev <dzenichev@sipwise.com> Date: Thu, 5 Oct 2023 10:41:18 +0200 Subject: [PATCH] MT#58441 Coverity Scan report introduced by 1bf894c This is a fix for the following found defect: *** CID 1568540: Null pointer dereferences (REVERSE_INULL) /daemon/sdp.c: 2065 in insert_codec_parameters() 2059 pt->payload_type, 2060 STR_FMT(&pt->format_parameters)); 2061 } 2062 if (s_dst->len) { 2063 /* append to the chop->output */ 2064 append_attr_to_gstring(s, s_dst->str, NULL, flags, >>> CID 1568540: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "cm" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 2065 (cm ? cm->type_id : MT_UNKNOWN)); 2066 } 2067 g_string_free(s_dst, TRUE); 2068 } 2069 2070 /* rtcp-fb */ Change-Id: I309fd6268b889ceaf32a58d2fbe17a8c891a95d6 --- daemon/sdp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/daemon/sdp.c b/daemon/sdp.c index c8ed2a7b2..6bb0d5055 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -2042,8 +2042,7 @@ static void insert_codec_parameters(GString *s, struct call_media *cm, pt->payload_type, STR_FMT(&pt->encoding_with_params)); /* append to the chop->output */ - append_attr_to_gstring(s, s_dst->str, NULL, flags, - (cm ? cm->type_id : MT_UNKNOWN)); + append_attr_to_gstring(s, s_dst->str, NULL, flags, cm->type_id); g_string_truncate(s_dst, 0); } @@ -2066,8 +2065,7 @@ static void insert_codec_parameters(GString *s, struct call_media *cm, } if (s_dst->len) { /* append to the chop->output */ - append_attr_to_gstring(s, s_dst->str, NULL, flags, - (cm ? cm->type_id : MT_UNKNOWN)); + append_attr_to_gstring(s, s_dst->str, NULL, flags, cm->type_id); } g_string_truncate(s_dst, 0); } @@ -2081,8 +2079,7 @@ static void insert_codec_parameters(GString *s, struct call_media *cm, pt->payload_type, STR_FMT(fb)); /* append to the chop->output */ - append_attr_to_gstring(s, s_dst->str, NULL, flags, - (cm ? cm->type_id : MT_UNKNOWN)); + append_attr_to_gstring(s, s_dst->str, NULL, flags, cm->type_id); } }