[FFmpeg-cvslog] vorbisenc: check all allocations for failure

Alexander Strasser eclipse7 at gmx.net
Sun Feb 26 18:18:01 CET 2012


Alexander Strasser wrote:
> Justin Ruggles wrote:
> > ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Wed Feb 22 19:23:18 2012 -0500| [be8d812c9635f31f69c30dff9ebf565a07a7dab7] | committer: Justin Ruggles
> > 
> > vorbisenc: check all allocations for failure
> [...]
> > @@ -167,6 +167,8 @@ static void ready_codebook(vorbis_enc_codebook *cb)
> >          int vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries);
> >          cb->dimentions = av_malloc(sizeof(float) * cb->nentries * cb->ndimentions);
> >          cb->pow2 = av_mallocz(sizeof(float) * cb->nentries);
> > +        if (!cb->dimentions || !cb->pow2)
> > +            return AVERROR(ENOMEM);
> 
>   this leaves open the possibility to leak one of the two allocations.
> 
>   A possible solution would be always trying to free both in the "error out"
> path (av_free(NULL) should never hurt).

  As Justin pointed out to me, this gets freed further down the call stack.

  After the error status of ready_codebook() is passed through
create_vorbis_context() to vorbis_encode_init() where on the
error path vorbis_encode_close() is called which frees the
codebooks of the vorbis_enc_context.

  So should be all OK on a 2nd look. Sorry for the noise.

  Alexander


More information about the ffmpeg-cvslog mailing list