Opened 2 years ago

Closed 2 years ago

#9537 closed defect (fixed)

avcodec_open2 segfault for h264_vaapi

Reported by: kurufu Owned by:
Priority: important Component: avcodec
Version: 4.4.3 Keywords: crash, VAAPI
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:
avcodec_open2 segfaults if you try to open vaapi with well formed but incorrect options.

How to reproduce:

#include <libavcodec/avcodec.h>    
int main(int argc, char *argv[]) {    
  AVDictionary *opts = NULL;             
  av_dict_set(&opts, "b", "2.5M", 0);                      
  AVCodec *codec = avcodec_find_encoder_by_name("h264_vaapi");     
  if (!codec)                      
  AVCodecContext *context = avcodec_alloc_context3(codec);    
  context->time_base = (AVRational){1, 60};       
  context->pix_fmt = AV_PIX_FMT_VAAPI;             
  context->width = 640;                            
  context->height = 480;                           
  if (avcodec_open2(context, codec, &opts) < 0)    

Build with gcc -o example main.c -lavcodec -lavutil on ffmpeg 4.4.1. Though the given options are not enough to correctly open the codec, (the error [h264_vaapi @ 0x55fc49a13c00] A hardware frames reference is required to associate the encoding device. is reported). Libavcodec then proceeds to segfault.

Preferably ffmpeg would not segfault when provided well formed input. Marking important as its a crash, feel free to re-prioritize if thats not the correct choice. Also preferably a fix would be backported if possible.

Change History (2)

comment:1 by kurufu, 2 years ago

Version: unspecified4.4.1

comment:2 by mkver, 2 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.