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

Michael Niedermayer michaelni at gmx.at
Fri Feb 3 20:13:34 CET 2012


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

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-cvslog/attachments/20120203/31f48459/attachment.asc>


More information about the ffmpeg-cvslog mailing list