[Ffmpeg-cvslog] r5996 - trunk/libavutil/mem.c
michael
subversion
Sun Aug 13 23:09:00 CEST 2006
Author: michael
Date: Sun Aug 13 23:09:00 2006
New Revision: 5996
Modified:
trunk/libavutil/mem.c
Log:
trying to fix av_realloc()
Modified: trunk/libavutil/mem.c
==============================================================================
--- trunk/libavutil/mem.c (original)
+++ trunk/libavutil/mem.c Sun Aug 13 23:09:00 2006
@@ -50,7 +50,7 @@
#endif
/* let's disallow possible ambiguous cases */
- if(size > (INT_MAX-16) )
+ if(size > (INT_MAX-16) || !size)
return NULL;
#ifdef MEMALIGN_HACK
@@ -109,14 +109,16 @@
#ifndef MEMALIGN_HACK
ptr= realloc(ptr, size);
- if(((int)ptr&15) || !ptr)
+assert(((int)((void*)0)&15) == 0); //for the null pointer pedants
+ if(!((int)ptr&15))
return ptr;
#endif
ptr2= av_malloc(size);
if(ptr && ptr2)
memcpy(ptr2, ptr, size);
- av_free(ptr);
+ if(ptr2 || !size)
+ av_free(ptr);
return ptr2;
}
More information about the ffmpeg-cvslog
mailing list