From 0de143fa3ec32d9ebb88f8e701837bff13f2cae5 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 28 May 2018 10:59:14 -0700 Subject: [PATCH] tests: qtdemux: Avoid using data beyond array and improve error msg Makes it easier to debug the failures as well as prevents problems reading out of bounds data. --- tests/check/elements/qtdemux.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/check/elements/qtdemux.c b/tests/check/elements/qtdemux.c index 0f9c61afb3..07acbfc441 100644 --- a/tests/check/elements/qtdemux.c +++ b/tests/check/elements/qtdemux.c @@ -197,11 +197,19 @@ qtdemux_probe_for_reconfig (GstPad * pad, GstPadProbeInfo * info, ReconfigTestData * data) { GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info); - GstEventType expected = data->expected_events[data->step]; + GstEventType expected; + + if (data->step < data->total_step) { + expected = data->expected_events[data->step]; + } else { + expected = GST_EVENT_UNKNOWN; + } GST_DEBUG ("Got event %p %s", event, GST_EVENT_TYPE_NAME (event)); - fail_unless (GST_EVENT_TYPE (event) == expected); + fail_unless (GST_EVENT_TYPE (event) == expected, + "Received unexpected event: %s (expected: %s)", + GST_EVENT_TYPE_NAME (event), gst_event_type_get_name (expected)); data->step++; if (GST_EVENT_TYPE (event) == GST_EVENT_EOS && data->step < data->total_step) { @@ -259,7 +267,7 @@ GST_START_TEST (test_qtdemux_duplicated_moov) data.expected_events = expected; data.expected_num_srcpad = 1; - data.total_step = G_N_ELEMENTS (expected);; + data.total_step = G_N_ELEMENTS (expected); /* The goal of this test is to check that qtdemux can properly handle * duplicated moov without redundant events and pad exposing