Skip to content
  • Filip Roséen's avatar
    codec/avcodec/video: only flush buffer if avcodec_is_open · 57c89366
    Filip Roséen authored and Rémi Denis-Courmont's avatar Rémi Denis-Courmont committed
    
    
    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
    information.
    
    Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
    57c89366