From d427b9bddfbaba1fed824477b1e3195fb105d5f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 23 Mar 2020 19:55:37 +0200 Subject: [PATCH] qtmux: Error out instead of crashing if reserved-max-duration is 0 or no samples could be created in prefill mode --- gst/isomp4/gstqtmux.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index 1bc39a5462..e5944dd690 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -3027,6 +3027,11 @@ gst_qt_mux_start_file (GstQTMux * qtmux) } else if (qtmux->fast_start) { qtmux->mux_mode = GST_QT_MUX_MODE_FAST_START; } else if (reserved_max_duration != GST_CLOCK_TIME_NONE) { + if (reserved_max_duration == 0) { + GST_ELEMENT_ERROR (qtmux, STREAM, MUX, + ("reserved-max-duration of 0 is not allowed"), (NULL)); + return GST_FLOW_ERROR; + } if (qtmux->reserved_prefill) qtmux->mux_mode = GST_QT_MUX_MODE_ROBUST_RECORDING_PREFILL; else @@ -5078,6 +5083,12 @@ find_best_pad (GstQTMux * qtmux) /* Find the exact offset where the next sample of this track is supposed * to be written at */ block_idx = current_block_idx = prefill_get_block_index (qtmux, qtpad); + if (!qtpad->samples || block_idx >= qtpad->samples->len) { + GST_ELEMENT_ERROR (qtmux, RESOURCE, SETTINGS, + ("Failed to create samples in prefill mode"), (NULL)); + return NULL; + } + sample_entry = &g_array_index (qtpad->samples, TrakBufferEntryInfo, block_idx); while (block_idx > 0) {