From a4bf15581731ea75ce1ff5f156779580e685bff1 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sat, 18 Dec 2004 19:36:59 +0000 Subject: [PATCH] gst/avi/gstavidemux.c: Work for truncated (unfinished download etc.) files. Fixes #160514. Original commit message from CVS: * gst/avi/gstavidemux.c: (gst_avi_demux_stream_index): Work for truncated (unfinished download etc.) files. Fixes #160514. --- ChangeLog | 5 +++++ gst/avi/gstavidemux.c | 20 ++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc6b63ecad..9c954bd7f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-12-18 Ronald S. Bultje + + * gst/avi/gstavidemux.c: (gst_avi_demux_stream_index): + Work for truncated (unfinished download etc.) files. Fixes #160514. + 2004-12-18 Ronald S. Bultje * ext/alsa/gstalsasink.c: (gst_alsa_sink_loop): diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c index 367e4b3264..8367177210 100644 --- a/gst/avi/gstavidemux.c +++ b/gst/avi/gstavidemux.c @@ -1198,17 +1198,29 @@ gst_avi_demux_stream_index (GstAviDemux * avi, pos_before = gst_bytestream_tell (riff->bs); /* skip movi - * - * FIXME: - * - we want to add error handling here so we can recover. */ + if (pos_before + 8 > length) { + return TRUE; + } else { + guint8 *data; + + if (gst_bytestream_peek_bytes (riff->bs, &data, 8) == 8) { + guint len = GST_READ_UINT32_LE (&data[4]); + + if (pos_before + 8 + len >= length) { + GST_WARNING ("No index avail"); + return TRUE; + } + } + } + /* hmm... */ if (!gst_riff_read_skip (riff)) return FALSE; /* assure that we've got data left */ pos_after = gst_bytestream_tell (riff->bs); if (pos_after + 8 > length) { - g_warning ("File said that it has an index, but there is no index data!"); + GST_WARNING ("File said that it has an index, but there is no index data!"); goto end; }