[x264-devel] Fix malloc of zero size

Anton Mitrofanov git at videolan.org
Sat Feb 19 00:34:08 CET 2011


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Thu Feb 10 05:05:53 2011 -0800| [1f69cb33c1dc6992fbe4092d7aa906534acdcac8] | committer: Jason Garrett-Glaser

Fix malloc of zero size
Caused x264 to fail with some settings on systems that return a NULL pointer for malloc(0), like Solaris.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=1f69cb33c1dc6992fbe4092d7aa906534acdcac8
---

 common/macroblock.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/common/macroblock.c b/common/macroblock.c
index e559ab1..24c2af9 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -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:



More information about the x264-devel mailing list