[FFmpeg-cvslog] mem: do not check for negative size

Vittorio Giovara git at videolan.org
Sat Oct 26 21:59:06 CEST 2013


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Fri Oct 25 16:41:12 2013 +0200| [b284e1ffe343d6697fb950d1ee517bafda8a9844] | committer: Anton Khirnov

mem: do not check for negative size

size_t is guaranteed to be unsigned

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b284e1ffe343d6697fb950d1ee517bafda8a9844
---

 libavutil/mem.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/mem.h b/libavutil/mem.h
index f51682b..99dc4cc 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -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);
 }



More information about the ffmpeg-cvslog mailing list