[Ffmpeg-devel] [PATCH] av_realloc, unneccesary memcpy and possibly leaks after r5992
Sun Aug 13 22:32:31 CEST 2006
On Sun, Aug 13, 2006 at 03:59:54PM +0200, Herv? W. wrote:
> in libavutil/mem.c after r5992:
> >#ifndef MEMALIGN_HACK
> > ptr= realloc(ptr, size);
> "If realloc() fails the original block is left untouched - it is not
> freed or moved"
> according to: http://man.he.net/man3/realloc
> (and possibly others)
> fixed in: " inputdata disappeared even after failed realloc.diff "
the line above is correct and the corresponding change is rejected
> > if(((int)ptr&15) || !ptr)
> if ((int)ptr&15) is "true", then ptr is unaligned and the data should
> be moved, not returned. And aligned memory was memcpy'd .
> fixed in: " aligned memory was moved anyway.diff "
> (and in: "inputdata disappeared even after failed realloc.diff " )
yes, a very silly typo, i will fix it soon
> > return ptr;
> > ptr2= av_malloc(size);
> > if(ptr && ptr2)
> > memcpy(ptr2, ptr, size);
> > av_free(ptr);
> if ptr2 was NULL, av_free is still called, which in my opinion breaks
> unnecessarily with "If realloc() fails the original block is left
> untouched - it is not freed or moved"
> fixed in: " inputdata disappeared even after failed realloc (part2).diff "
my code is buggy, sadly yours too, it will leak if size=0
ill try to fix it, dont hesitate to review my change on svnlog and point
me to any further cases i missed, seems this isnt as easy as it looked
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is
More information about the ffmpeg-devel