aboutsummaryrefslogtreecommitdiff
path: root/libavutil/mem.c
diff options
context:
space:
mode:
authorMichael Niedermayer2006-08-13 21:09:00 +0000
committerMichael Niedermayer2006-08-13 21:09:00 +0000
commit732692d94cf3048799c848799ee601ffc2f768b0 (patch)
treecb74737cd380f364c0bc3bbe6db9478fc33e25e3 /libavutil/mem.c
parent0ccd1bb5376a9fd40156d737dc773e8fe798cf31 (diff)
trying to fix av_realloc()
Originally committed as revision 5996 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/mem.c')
-rw-r--r--libavutil/mem.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 61d886dc5d..cdfefd6055 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -50,7 +50,7 @@ void *av_malloc(unsigned int size)
#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 @@ void *av_realloc(void *ptr, unsigned int size)
#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;
}