]> git.sesse.net Git - ffmpeg/commitdiff
avutil/mem: Also poison new av_realloc-allocated blocks
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Mon, 26 Apr 2021 16:34:31 +0000 (18:34 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Fri, 30 Apr 2021 08:24:32 +0000 (10:24 +0200)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
libavutil/mem.c

index cfb6d8ab8ffa6c6d51f325d4d8bbe7dc0922871f..fa227f5e120f9e9931f6eb06fd56aa1ffbb86e4b 100644 (file)
@@ -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)