From 212121536fc2c1fadd10ca0897759e965bcb4235 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 15 Jun 2006 08:50:09 +0000 Subject: gst/qtdemux/qtdemux.c: Don't crash on files with 0 samples, EOS immediatly instead. Original commit message from CVS: * gst/qtdemux/qtdemux.c: (gst_qtdemux_loop_state_header), (gst_qtdemux_prepare_current_sample), (gst_qtdemux_advance_sample), (gst_qtdemux_add_stream): Don't crash on files with 0 samples, EOS immediatly instead. Fixes #344944. --- gst/qtdemux/qtdemux.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'gst/qtdemux') diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 2510a859..a7d2c30f 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -1016,8 +1016,8 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux) qtdemux->state = QTDEMUX_STATE_MOVIE; GST_DEBUG_OBJECT (qtdemux, "switching state to STATE_MOVIE (%d)", qtdemux->state); - } break; + } ed_edd_and_eddy: default:{ GST_LOG ("unknown %08x '%" GST_FOURCC_FORMAT "' at %d", @@ -1150,6 +1150,9 @@ gst_qtdemux_prepare_current_sample (GstQTDemux * qtdemux, if (stream->segment_index != seg_idx) gst_qtdemux_activate_segment (qtdemux, stream, seg_idx, time_position); + if (stream->sample_index >= stream->n_samples) + goto eos; + /* now get the info for the sample we're at */ sample = &stream->samples[stream->sample_index]; @@ -1186,7 +1189,7 @@ gst_qtdemux_advance_sample (GstQTDemux * qtdemux, QtDemuxStream * stream) segment = &stream->segments[stream->segment_index]; /* reached the last sample, we need the next segment */ - if (stream->sample_index == stream->n_samples) + if (stream->sample_index >= stream->n_samples) goto next_segment; /* get next sample */ @@ -1410,12 +1413,11 @@ invalid_state: } /* - next_entry_size - - Returns the size of the first entry at the current offset. - If -1, there are none (which means EOS or empty file). -*/ - + * next_entry_size + * + * Returns the size of the first entry at the current offset. + * If -1, there are none (which means EOS or empty file). + */ static guint64 next_entry_size (GstQTDemux * demux) { @@ -1753,6 +1755,7 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux, /* fps is calculated base on the duration of the first frames since * qt does not have a fixed framerate. */ if ((stream->n_samples == 1) && (stream->min_duration == 0)) { + /* still frame */ stream->fps_n = 0; stream->fps_d = 1; } else { @@ -1768,6 +1771,7 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux, "width", G_TYPE_INT, stream->width, "height", G_TYPE_INT, stream->height, "framerate", GST_TYPE_FRACTION, stream->fps_n, stream->fps_d, NULL); + if ((stream->bits_per_sample & 0x1F) == 8) { const guint32 *palette_data = NULL; -- cgit v1.2.1