[FFmpeg-devel] [PATCH] mem: heap memory poisoning.

Michael Niedermayer michaelni at gmx.at
Mon Jul 2 20:43:00 CEST 2012


On Mon, Jul 02, 2012 at 07:34:13PM +0200, Clément Bœsch wrote:
> On Mon, Jul 02, 2012 at 07:32:04PM +0200, Clément Bœsch wrote:
> > Enable it by default with FATE.
> > limitation: not random, and not supported with realloc.
> > ---
> >  configure       | 2 ++
> >  libavutil/mem.c | 7 ++++++-
> >  tests/fate.sh   | 1 +
> >  3 files changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/configure b/configure
> > index a1346fa..cb8a04d 100755
> > --- a/configure
> > +++ b/configure
> > @@ -286,6 +286,7 @@ Developer options (useful when working on FFmpeg itself):
> >    --disable-stripping      disable stripping of executables and shared libraries
> >    --assert-level=level     0(default), 1 or 2, amount of assertion testing,
> >                             2 causes a slowdown at runtime.
> > +  --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data
> >    --valgrind=VALGRIND      run "make fate" tests through valgrind to detect memory
> >                             leaks and errors, using the specified valgrind binary.
> >                             Cannot be combined with --target-exec
> > @@ -1080,6 +1081,7 @@ CONFIG_LIST="
> >      lsp
> >      mdct
> >      memalign_hack
> > +    memory_poisoning
> >      mpegaudiodsp
> >      network
> >      nonfree
> > diff --git a/libavutil/mem.c b/libavutil/mem.c
> > index 385ace0..20485a8 100644
> > --- a/libavutil/mem.c
> > +++ b/libavutil/mem.c
> > @@ -125,8 +125,13 @@ void *av_malloc(size_t size)
> >  #else
> >      ptr = malloc(size);
> >  #endif
> > -    if(!ptr && !size)
> > +    if(!ptr && !size) {
> > +        size = 1;
> >          ptr= av_malloc(1);
> > +    }
> > +#if CONFIG_MEMORY_POISONING
> > +    memset(ptr, 0x2a, size);
> 
> mpf. Added a if (ptr) locally.

LGTM

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- 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-devel/attachments/20120702/8c1debe9/attachment.asc>


More information about the ffmpeg-devel mailing list