From: Sebastian Dröge Date: Thu, 30 Jun 2022 06:02:00 +0000 (+0300) Subject: sdpmessage: Don't set SDP medias from caps without media/payload/clock-rate fields X-Git-Tag: 1.22.0~1342 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f71a467fcffd39650c460d9fa2788c7578ecb5a;p=platform%2Fupstream%2Fgstreamer.git sdpmessage: Don't set SDP medias from caps without media/payload/clock-rate fields Previously it would've silently failed reading the payload/clock-rate and instead would've used some random value that happened to be on the stack. Part-of: --- diff --git a/subprojects/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.c b/subprojects/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.c index 9ad2aec..17bb1c3 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.c @@ -3814,15 +3814,25 @@ gst_sdp_media_set_media_from_caps (const GstCaps * caps, GstSDPMedia * media) /* get media type and payload for the m= line */ caps_str = gst_structure_get_string (s, "media"); + if (!caps_str) { + GST_ERROR ("ignoring stream without media type"); + goto error; + } gst_sdp_media_set_media (media, caps_str); - gst_structure_get_int (s, "payload", &caps_pt); + if (!gst_structure_get_int (s, "payload", &caps_pt)) { + GST_ERROR ("ignoring stream without payload type"); + goto error; + } tmp = g_strdup_printf ("%d", caps_pt); gst_sdp_media_add_format (media, tmp); g_free (tmp); /* get clock-rate, media type and params for the rtpmap attribute */ - gst_structure_get_int (s, "clock-rate", &caps_rate); + if (!gst_structure_get_int (s, "clock-rate", &caps_rate)) { + GST_ERROR ("ignoring stream without payload type"); + goto error; + } caps_enc = gst_structure_get_string (s, "encoding-name"); caps_params = gst_structure_get_string (s, "encoding-params");