Hi!

Attached patch makes the alloc array functions more similar to
av_malloc, depending on max_alloc_size instead of INT_MAX.

Allows a work-around for ticket #7140

Please comment, Carl Eugen
From 7ae240a9f7885130251031aba5d0764b11947fec Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffm...@gmail.com>
Date: Sat, 4 Apr 2020 00:37:03 +0200
Subject: [PATCH] lavu/mem: Make alloc array functions more similar to
 av_malloc().

Do not limit the array allocation functions to allocations of INT_MAX,
instead depend on max_alloc_size like av_malloc().

Allows a workaround for ticket #7140.
---
 libavutil/mem.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index 88fe09b179..8783b85a45 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -183,21 +183,21 @@ int av_reallocp(void *ptr, size_t size)
 
 void *av_malloc_array(size_t nmemb, size_t size)
 {
-    if (!size || nmemb >= INT_MAX / size)
+    if (!size || nmemb >= SIZE_MAX / size)
         return NULL;
     return av_malloc(nmemb * size);
 }
 
 void *av_mallocz_array(size_t nmemb, size_t size)
 {
-    if (!size || nmemb >= INT_MAX / size)
+    if (!size || nmemb >= SIZE_MAX / size)
         return NULL;
     return av_mallocz(nmemb * size);
 }
 
 void *av_realloc_array(void *ptr, size_t nmemb, size_t size)
 {
-    if (!size || nmemb >= INT_MAX / size)
+    if (!size || nmemb >= SIZE_MAX / size)
         return NULL;
     return av_realloc(ptr, nmemb * size);
 }
@@ -243,7 +243,7 @@ void *av_mallocz(size_t size)
 
 void *av_calloc(size_t nmemb, size_t size)
 {
-    if (size <= 0 || nmemb >= INT_MAX / size)
+    if (size <= 0 || nmemb >= SIZE_MAX / size)
         return NULL;
     return av_mallocz(nmemb * size);
 }
-- 
2.24.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to