Commit b284e1ff authored by Vittorio Giovara's avatar Vittorio Giovara Committed by Anton Khirnov

mem: do not check for negative size

size_t is guaranteed to be unsigned
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent 4e326ec7
...@@ -91,7 +91,7 @@ void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); ...@@ -91,7 +91,7 @@ void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
*/ */
av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size) av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size)
{ {
if (size <= 0 || nmemb >= INT_MAX / size) if (!size || nmemb >= INT_MAX / size)
return NULL; return NULL;
return av_malloc(nmemb * size); return av_malloc(nmemb * size);
} }
...@@ -204,7 +204,7 @@ void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); ...@@ -204,7 +204,7 @@ void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
*/ */
av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size) av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size)
{ {
if (size <= 0 || nmemb >= INT_MAX / size) if (!size || nmemb >= INT_MAX / size)
return NULL; return NULL;
return av_mallocz(nmemb * size); return av_mallocz(nmemb * size);
} }
......
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