[vlc-devel] [PATCH 2/2] vlc_alloc: use multiplication overflow helper

RĂ©mi Denis-Courmont remi at remlab.net
Sun Nov 12 10:27:09 CET 2017


---
 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);
 }
 
 /*****************************************************************************
-- 
2.15.0



More information about the vlc-devel mailing list