[FFmpeg-devel] [PATCH] lavu: define FF_MEMORY_POISON and use it

Clément Bœsch ubitux at gmail.com
Sun May 12 23:32:12 CEST 2013


On Sun, May 12, 2013 at 02:03:17PM +0200, Stefano Sabatini wrote:
> On date Sunday 2013-05-12 13:49:25 +0200, Clément Bœsch encoded:
> > On Sun, May 12, 2013 at 01:39:40PM +0200, Stefano Sabatini wrote:
> > > Allow single-place definition of constant used to fill poisoned memory.
> > > ---
> > >  libavutil/buffer.c   |    2 +-
> > >  libavutil/internal.h |    2 ++
> > >  libavutil/mem.c      |    2 +-
> > >  3 files changed, 4 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/libavutil/buffer.c b/libavutil/buffer.c
> > > index a5fc8d7..e9bf54b 100644
> > > --- a/libavutil/buffer.c
> > > +++ b/libavutil/buffer.c
> > > @@ -288,7 +288,7 @@ static void pool_release_buffer(void *opaque, uint8_t *data)
> > >      AVBufferPool *pool = buf->pool;
> > >  
> > >      if(CONFIG_MEMORY_POISONING)
> > > -        memset(buf->data, 0x2a, pool->size);
> > > +        memset(buf->data, FF_MEMORY_POISON, pool->size);
> > >  
> > >      add_to_pool(buf);
> > >      if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
> > > diff --git a/libavutil/internal.h b/libavutil/internal.h
> > > index 76018a8..c5835fb 100644
> > > --- a/libavutil/internal.h
> > > +++ b/libavutil/internal.h
> > > @@ -66,6 +66,8 @@
> > >  #    define INT_BIT (CHAR_BIT * sizeof(int))
> > >  #endif
> > >  
> > > +#define FF_MEMORY_POISON 0x2a
> > > +
> > >  // Some broken preprocessors need a second expansion
> > >  // to be forced to tokenize __VA_ARGS__
> > >  #define E1(x) x
> > > diff --git a/libavutil/mem.c b/libavutil/mem.c
> > > index 03bf2c8..9b22609 100644
> > > --- a/libavutil/mem.c
> > > +++ b/libavutil/mem.c
> > > @@ -133,7 +133,7 @@ void *av_malloc(size_t size)
> > >      }
> > >  #if CONFIG_MEMORY_POISONING
> > >      if (ptr)
> > > -        memset(ptr, 0x2a, size);
> > > +        memset(ptr, FF_MEMORY_POISON, size);
> > >  #endif
> > >      return ptr;
> > >  }
> > 
> 
> > What about adding it to configure? (shouldn't be much effort, possibly
> > just adding too lines, see around L4600).
> 
> I prefer not to spend more time on this (figuring out all the input
> verification issues etc.) also it can be done after this patch with no
> harm.

Well OK, patch LGTM

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130512/bc7b708b/attachment.asc>


More information about the ffmpeg-devel mailing list