[FFmpeg-cvslog] avcodec: Add av_fast_padded_malloc().

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Feb 3 20:24:34 CET 2012


On Fri, Feb 03, 2012 at 08:13:34PM +0100, Michael Niedermayer wrote:
> On Fri, Feb 03, 2012 at 07:11:34PM +0100, Reimar Döffinger wrote:
> > On Fri, Feb 03, 2012 at 04:55:12PM +0100, Michael Niedermayer wrote:
> > > On Thu, Feb 02, 2012 at 09:50:44AM +0100, Reimar Döffinger wrote:
> > > > On Thu, Feb 02, 2012 at 02:46:27AM +0100, Janne Grunau wrote:
> > > > > ffmpeg | branch: master | Janne Grunau <janne-libav at jannau.net> | Tue Jan 31 15:40:11 2012 +0000| [316fc7443b05f8c8b494443f2dfe590434796902] | committer: Janne Grunau
> > > > > 
> > > > > avcodec: Add av_fast_padded_malloc().
> > > > > 
> > > > > Wrapper around av_fast_malloc() that keeps FF_INPUT_BUFFER_PADDING_SIZE
> > > > > zero-padded bytes at the end of the used buffer.
> > > > > 
> > > > > Based on a patch by Reimar Döffinger <Reimar.Doeffinger at gmx.de>.
> > > > 
> > > > No idea if you merged this, but this variant will not fix
> > > > valgrind failures mine did since it does not always ensure
> > > > all data in the buffer has been initialized at some point.
> > > 
> > > I mixed and shaked them together IIRC seems fate valgrind is still
> > > green so i naively assume i didnt mess up
> 
> This diff that went in:
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 0df3d7f..f21e36f 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -91,7 +91,7 @@ void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
>  {
>      uint8_t **p = ptr;
>      if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
> -        *p = NULL;
> +        av_freep(p);
>          *size = 0;
>          return;
>      }
> 
> and this should fix some memleaks in the failure case

Ups. Yes, embarrassing, that definitely is right.
But nothing will have broken then, great.
And maybe we'll get another valgrind machine that
runs the full program somewhen.


More information about the ffmpeg-cvslog mailing list