Opened 4 months ago

Closed 3 months ago

#7074 closed defect (fixed)

Do not use av_free() to free avcodec_alloc_context3() return value

Reported by: PanBian Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Details: In avcodec_dct_init(), the return value of avcodec_alloc_context3() (called at line 90) is freed with av_free() (at line 127). I think the expected paired function is avcodec_free_context(). For your convenience, I paste related bugs as follows:

 88 int avcodec_dct_init(AVDCT *dsp)
 89 {
 90     AVCodecContext *avctx = avcodec_alloc_context3(NULL);
 91 
 92     if (!avctx)
 93         return AVERROR(ENOMEM);
 94 
 95     avctx->idct_algo = dsp->idct_algo;
 96     avctx->dct_algo  = dsp->dct_algo;
 97     avctx->bits_per_raw_sample = dsp->bits_per_sample;
        ...
125 
126     avcodec_close(avctx);
127     av_free(avctx);
128 
129     return 0;
130 }

Thanks!

Change History (3)

comment:1 follow-up: Changed 4 months ago by cehoyos

Is there a reason why you didn't send a patch - made with git format-patch - to the FFmpeg development mailing list?

comment:2 in reply to: ↑ 1 Changed 4 months ago by PanBian

Replying to cehoyos:

Is there a reason why you didn't send a patch - made with git format-patch - to the FFmpeg development mailing list?

I got a problem on compiling the source code on my machine. So I post the bug here. I will try to solve the compiling problem. I am willing to make a patch if the bug is still not fixed then.

comment:3 Changed 3 months ago by jamrial

  • Component changed from undetermined to avcodec
  • Resolution set to fixed
  • Status changed from new to closed
  • Version changed from unspecified to git-master
Note: See TracTickets for help on using tickets.