Commit 7c84e7d3 authored by Clément Bœsch's avatar Clément Bœsch

mem: heap memory poisoning.

Enable it by default with FATE.
limitation: not random, and not supported with realloc.
parent 2278a3e5
...@@ -286,6 +286,7 @@ Developer options (useful when working on FFmpeg itself): ...@@ -286,6 +286,7 @@ Developer options (useful when working on FFmpeg itself):
--disable-stripping disable stripping of executables and shared libraries --disable-stripping disable stripping of executables and shared libraries
--assert-level=level 0(default), 1 or 2, amount of assertion testing, --assert-level=level 0(default), 1 or 2, amount of assertion testing,
2 causes a slowdown at runtime. 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 --valgrind=VALGRIND run "make fate" tests through valgrind to detect memory
leaks and errors, using the specified valgrind binary. leaks and errors, using the specified valgrind binary.
Cannot be combined with --target-exec Cannot be combined with --target-exec
...@@ -1080,6 +1081,7 @@ CONFIG_LIST=" ...@@ -1080,6 +1081,7 @@ CONFIG_LIST="
lsp lsp
mdct mdct
memalign_hack memalign_hack
memory_poisoning
mpegaudiodsp mpegaudiodsp
network network
nonfree nonfree
......
...@@ -125,8 +125,14 @@ void *av_malloc(size_t size) ...@@ -125,8 +125,14 @@ void *av_malloc(size_t size)
#else #else
ptr = malloc(size); ptr = malloc(size);
#endif #endif
if(!ptr && !size) if(!ptr && !size) {
size = 1;
ptr= av_malloc(1); ptr= av_malloc(1);
}
#if CONFIG_MEMORY_POISONING
if (ptr)
memset(ptr, 0x2a, size);
#endif
return ptr; return ptr;
} }
......
...@@ -45,6 +45,7 @@ configure()( ...@@ -45,6 +45,7 @@ configure()(
--prefix="${inst}" \ --prefix="${inst}" \
--samples="${samples}" \ --samples="${samples}" \
--enable-gpl \ --enable-gpl \
--enable-memory-poisoning \
${arch:+--arch=$arch} \ ${arch:+--arch=$arch} \
${cpu:+--cpu="$cpu"} \ ${cpu:+--cpu="$cpu"} \
${cross_prefix:+--cross-prefix="$cross_prefix"} \ ${cross_prefix:+--cross-prefix="$cross_prefix"} \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment