audioconvert, audioresample, audiofilter: fix divide by 0 for input buffer without...
authorTim-Philipp Müller <tim@centricular.com>
Sat, 26 Nov 2022 08:23:59 +0000 (09:23 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 26 Nov 2022 08:47:49 +0000 (08:47 +0000)
gst-launch-1.0 audiotestsrc ! udpsink host=127.0.0.1
gst-launch-1.0 udpsrc ! audioconvert ! autoaudiosink

would crash with a floating point exception when clipping the input
buffer owing to a division by zero because no caps event was received.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3469>

subprojects/gst-plugins-base/gst-libs/gst/audio/gstaudiofilter.c
subprojects/gst-plugins-base/gst/audioconvert/gstaudioconvert.c
subprojects/gst-plugins-base/gst/audioresample/gstaudioresample.c

index e6ad740..0039833 100644 (file)
@@ -180,6 +180,11 @@ gst_audio_filter_submit_input_buffer (GstBaseTransform * btrans,
   GstAudioFilter *filter = GST_AUDIO_FILTER (btrans);
 
   if (btrans->segment.format == GST_FORMAT_TIME) {
+    if (!GST_AUDIO_INFO_IS_VALID (&filter->info)) {
+      GST_WARNING_OBJECT (filter, "Got buffer, but not negotiated yet!");
+      return GST_FLOW_NOT_NEGOTIATED;
+    }
+
     input =
         gst_audio_buffer_clip (input, &btrans->segment, filter->info.rate,
         filter->info.bpf);
index 896ef9c..474dcae 100644 (file)
@@ -934,6 +934,11 @@ gst_audio_convert_submit_input_buffer (GstBaseTransform * base,
   GstAudioConvert *this = GST_AUDIO_CONVERT (base);
 
   if (base->segment.format == GST_FORMAT_TIME) {
+    if (!GST_AUDIO_INFO_IS_VALID (&this->in_info)) {
+      GST_WARNING_OBJECT (this, "Got buffer, but not negotiated yet!");
+      return GST_FLOW_NOT_NEGOTIATED;
+    }
+
     input =
         gst_audio_buffer_clip (input, &base->segment, this->in_info.rate,
         this->in_info.bpf);
index fbfb5ca..d059575 100644 (file)
@@ -977,6 +977,11 @@ gst_audio_resample_submit_input_buffer (GstBaseTransform * base,
   GstAudioResample *resample = GST_AUDIO_RESAMPLE (base);
 
   if (base->segment.format == GST_FORMAT_TIME) {
+    if (!GST_AUDIO_INFO_IS_VALID (&resample->in)) {
+      GST_WARNING_OBJECT (resample, "Got buffer, but not negotiated yet!");
+      return GST_FLOW_NOT_NEGOTIATED;
+    }
+
     input =
         gst_audio_buffer_clip (input, &base->segment, resample->in.rate,
         resample->in.bpf);