aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/mem.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-26 18:34:31 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-30 10:24:32 +0200
commit8b83a4a885e3b92bd09354d6cb182fca47f80973 (patch)
tree12a5ce05b5ac85a09a2d0d2eb96e6bb9041a13b0 /libavutil/mem.c
parent4796ec5d4ea00a86f9f6732653469e682e5266da (diff)
downloadffmpeg-8b83a4a885e3b92bd09354d6cb182fca47f80973.tar.gz
avutil/mem: Also poison new av_realloc-allocated blocks
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavutil/mem.c')
-rw-r--r--libavutil/mem.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c
index cfb6d8ab8f..fa227f5e12 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -133,14 +133,20 @@ void *av_malloc(size_t size)
void *av_realloc(void *ptr, size_t size)
{
+ void *ret;
if (size > max_alloc_size)
return NULL;
#if HAVE_ALIGNED_MALLOC
- return _aligned_realloc(ptr, size + !size, ALIGN);
+ ret = _aligned_realloc(ptr, size + !size, ALIGN);
#else
- return realloc(ptr, size + !size);
+ ret = realloc(ptr, size + !size);
#endif
+#if CONFIG_MEMORY_POISONING
+ if (ret && !ptr)
+ memset(ret, FF_MEMORY_POISON, size);
+#endif
+ return ret;
}
void *av_realloc_f(void *ptr, size_t nelem, size_t elsize)