From 43856a0735fb75afdc53d298ba5ee7b748b0e09b Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Wed, 29 Dec 2021 15:02:03 +0000 Subject: [PATCH] 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: --- subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c index 04261c5a20..3d31b4a0c3 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c @@ -89,6 +89,8 @@ _gst_structure_take_structure (GstStructure * s, const char *fieldname, { GValue v = G_VALUE_INIT; + g_return_if_fail (GST_IS_STRUCTURE (*value_s)); + g_value_init (&v, GST_TYPE_STRUCTURE); 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 * 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, source_stats, NULL);