Commit 57c89366 authored by Filip Roséen's avatar Filip Roséen Committed by Rémi Denis-Courmont
Browse files

codec/avcodec/video: only flush buffer if avcodec_is_open

This patch fixes a crash when trying to invoke avcodec_flush_buffers
on an not-yet-opened AvCodecContext*.

The previous if-condition is faulty because nothing guarantees that
the state of the variable in question reflects whether we are in a
state where p_sys->p_context is valid; instead it has been
replaced by a call to "avcodec_is_open".

refs: #17080


"p_sys->p_context" is opened (through avcodec_open2) in "ffmpeg_OpenCodec",
which is not guaranteed to have been called prior to "EndVideoDec" (due to
potential missing data required for codec initialization).

See the implementation of OpenVideoCodec in codec/avcodec/video.c for more
Signed-off-by: Rémi Denis-Courmont's avatarRémi Denis-Courmont <>
parent 737089f0
......@@ -935,7 +935,7 @@ void EndVideoDec( decoder_t *p_dec )
post_mt( p_sys );
/* do not flush buffers if codec hasn't been opened (theora/vorbis/VC1) */
if( p_sys->p_context->codec )
if( avcodec_is_open( p_sys->p_context ) )
avcodec_flush_buffers( p_sys->p_context );
wait_mt( p_sys );
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment