[FFmpeg-trac] #7074(undetermined:new): Do not use av_free() to free avcodec_alloc_context3() return value

FFmpeg trac at avcodec.org
Fri Mar 9 02:28:55 EET 2018


#7074: Do not use av_free() to free avcodec_alloc_context3() return value
-------------------------------------+-------------------------------------
             Reporter:  PanBian      |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 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:

   {{{#!c
  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!

--
Ticket URL: <https://trac.ffmpeg.org/ticket/7074>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list