mem: heap memory poisoning.
authorClément Bœsch <ubitux@gmail.com>
Mon, 2 Jul 2012 17:31:35 +0000 (19:31 +0200)
committerClément Bœsch <ubitux@gmail.com>
Mon, 2 Jul 2012 19:02:15 +0000 (21:02 +0200)
Enable it by default with FATE.
limitation: not random, and not supported with realloc.

configure
libavutil/mem.c
tests/fate.sh

index a1346fa..cb8a04d 100755 (executable)
--- a/configure
+++ b/configure
@@ -286,6 +286,7 @@ Developer options (useful when working on FFmpeg itself):
   --disable-stripping      disable stripping of executables and shared libraries
   --assert-level=level     0(default), 1 or 2, amount of assertion testing,
                            2 causes a slowdown at runtime.
+  --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data
   --valgrind=VALGRIND      run "make fate" tests through valgrind to detect memory
                            leaks and errors, using the specified valgrind binary.
                            Cannot be combined with --target-exec
@@ -1080,6 +1081,7 @@ CONFIG_LIST="
     lsp
     mdct
     memalign_hack
+    memory_poisoning
     mpegaudiodsp
     network
     nonfree
index 385ace0..8ec226b 100644 (file)
@@ -125,8 +125,14 @@ void *av_malloc(size_t size)
 #else
     ptr = malloc(size);
 #endif
-    if(!ptr && !size)
+    if(!ptr && !size) {
+        size = 1;
         ptr= av_malloc(1);
+    }
+#if CONFIG_MEMORY_POISONING
+    if (ptr)
+        memset(ptr, 0x2a, size);
+#endif
     return ptr;
 }
 
index a7b15cd..0bf10ab 100755 (executable)
@@ -45,6 +45,7 @@ configure()(
         --prefix="${inst}"                                              \
         --samples="${samples}"                                          \
         --enable-gpl                                                    \
+        --enable-memory-poisoning                                       \
         ${arch:+--arch=$arch}                                           \
         ${cpu:+--cpu="$cpu"}                                            \
         ${cross_prefix:+--cross-prefix="$cross_prefix"}                 \