[Ffmpeg-devel] [PATCH] minor improvements to libavcodec/mem.c

Hervé W. H.O.W.aka.V+ffmpeg
Fri Jun 30 00:42:12 CEST 2006


On 30/06/06, Michael Niedermayer <michaelni at gmx.at> wrote:
> [...]
> > -#endif
> >
> >      /* lets disallow possible ambiguous cases */
> > +    if(size > (INT_MAX-16) )
> > +        return NULL;
> > +#else
> >      if(size > INT_MAX)
> >          return NULL;
> > +#endif
>
> just always subtract 16, this isnt worth a special case
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Thanks for your reply. I made that change and the new version should
find itself attached to this e-mail.
Any other comments? On the patch or my previous mail on this topic?

-V
-------------- next part --------------
Index: libavcodec/mem.c
===================================================================
--- libavcodec/mem.c	(revision 5544)
+++ libavcodec/mem.c	(working copy)
@@ -50,11 +50,13 @@
 #endif
 
     /* lets disallow possible ambiguous cases */
-    if(size > INT_MAX)
+    if(size > (INT_MAX-16) )
         return NULL;
 
 #ifdef MEMALIGN_HACK
-    ptr = malloc(size+16+1);
+    ptr = malloc(size+16);
+    if(!ptr)
+        return ptr;
     diff= ((-(long)ptr - 1)&15) + 1;
     ptr += diff;
     ((char*)ptr)[-1]= diff;
@@ -104,7 +106,7 @@
 #endif
 
     /* lets disallow possible ambiguous cases */
-    if(size > INT_MAX)
+    if(size > (INT_MAX-16) )
         return NULL;
 
 #ifdef MEMALIGN_HACK



More information about the ffmpeg-devel mailing list