webrtcstats: Fix null pointer dereference

If there is no jitterbuffer stats we should not attempt to store them in the
global stats structure.

Also add a g_return_if_fail in _gst_structure_take_structure() about this
because it is a programmer error to pass an invalid pointer address there.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1479>
This commit is contained in:
Philippe Normand 2021-12-29 15:02:03 +00:00
parent 13f0128f7e
commit 43856a0735

View file

@ -89,6 +89,8 @@ _gst_structure_take_structure (GstStructure * s, const char *fieldname,
{ {
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
g_return_if_fail (GST_IS_STRUCTURE (*value_s));
g_value_init (&v, GST_TYPE_STRUCTURE); g_value_init (&v, GST_TYPE_STRUCTURE);
g_value_take_boxed (&v, *value_s); g_value_take_boxed (&v, *value_s);
@ -543,7 +545,9 @@ _get_stats_from_rtp_source_stats (GstWebRTCBin * webrtc,
/* Store the raw stats from GStreamer into the structure for advanced /* Store the raw stats from GStreamer into the structure for advanced
* information. * information.
*/ */
_gst_structure_take_structure (in, "gst-rtpjitterbuffer-stats", &jb_stats); if (jb_stats)
_gst_structure_take_structure (in, "gst-rtpjitterbuffer-stats",
&jb_stats);
gst_structure_set (in, "gst-rtpsource-stats", GST_TYPE_STRUCTURE, gst_structure_set (in, "gst-rtpsource-stats", GST_TYPE_STRUCTURE,
source_stats, NULL); source_stats, NULL);