From c68683c15f88798b72e5f10f415e2d206a3074bc Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 27 Jun 2012 16:38:38 +0200 Subject: [PATCH] videodecoder: avoid crash when getting duration Check that we have a valid output_state before attempting to use it to calculate the duration of a buffer. It is possible that we don't have a state yet, for example when we are dropping the first buffers. --- gst-libs/gst/video/gstvideodecoder.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 77e37da465..9d2149c612 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -2342,6 +2342,11 @@ gst_video_decoder_get_frame_duration (GstVideoDecoder * decoder, { GstVideoCodecState *state = decoder->priv->output_state; + /* it's possible that we don't have a state yet when we are dropping the + * initial buffers */ + if (state == NULL) + return GST_CLOCK_TIME_NONE; + if (state->info.fps_d == 0 || state->info.fps_n == 0) { return GST_CLOCK_TIME_NONE; }