1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

mem: do not check for negative size

size_t is guaranteed to be unsigned

Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
Vittorio Giovara 2013-10-25 16:41:12 +02:00 committed by Anton Khirnov
parent 4e326ec769
commit b284e1ffe3

View File

@ -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)
{
if (size <= 0 || nmemb >= INT_MAX / size)
if (!size || nmemb >= INT_MAX / size)
return NULL;
return av_malloc(nmemb * size);
}
@ -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)
{
if (size <= 0 || nmemb >= INT_MAX / size)
if (!size || nmemb >= INT_MAX / size)
return NULL;
return av_mallocz(nmemb * size);
}