[vlc-commits] vlc_alloc: use multiplication overflow helper

Rémi Denis-Courmont git at videolan.org
Sun Nov 12 11:49:35 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov 12 11:27:09 2017 +0200| [d375f18a4714c11438be588572e2dc9aa683953a] | committer: Thomas Guillem

vlc_alloc: use multiplication overflow helper

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 include/vlc_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index e3d7086ff7..053ed714b1 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -961,7 +961,7 @@ VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t )
 VLC_USED VLC_MALLOC
 static inline void *vlc_alloc(size_t count, size_t size)
 {
-    return likely(count * size >= size) ? malloc(count * size) : NULL;
+    return mul_overflow(count, size, &size) ? NULL : malloc(size);
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list