]> git.videolan.org Git - x264.git/commitdiff
Fix malloc of zero size
authorAnton Mitrofanov <BugMaster@narod.ru>
Thu, 10 Feb 2011 13:05:53 +0000 (05:05 -0800)
committerJason Garrett-Glaser <jason@x264.com>
Fri, 18 Feb 2011 09:51:38 +0000 (01:51 -0800)
Caused x264 to fail with some settings on systems that return a NULL pointer for malloc(0), like Solaris.

common/macroblock.c

index e559ab173ba5ebe9b9e1bea94bcaf6c794b61a95..24c2af92db138408b33691446d675e95b5b214a5 100644 (file)
@@ -340,7 +340,10 @@ int x264_macroblock_thread_allocate( x264_t *h, int b_lookahead )
     }
     int buf_mbtree = h->param.rc.b_mb_tree * ((h->mb.i_mb_width+3)&~3) * sizeof(int);
     scratch_size = X264_MAX( scratch_size, buf_mbtree );
-    CHECKED_MALLOC( h->scratch_buffer, scratch_size );
+    if( scratch_size )
+        CHECKED_MALLOC( h->scratch_buffer, scratch_size );
+    else
+        h->scratch_buffer = NULL;
 
     return 0;
 fail: