[vlc-commits] vlc_alloc: use multiplication overflow helper

Rémi Denis-Courmont git at videolan.org
Sun Nov 12 14:25:46 CET 2017


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

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=aebbbf02881ca5b536539c96085ae62bd38c0e53
---

 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 bba58a101d..8c89aef556 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