[vlc-commits] objres: use add_overflow()

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


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov 12 19:12:41 2017 +0200| [a0749ab9207eb14eb2377e28429e7c362f1f0fc4] | committer: Rémi Denis-Courmont

objres: use add_overflow()

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

 src/misc/objres.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/misc/objres.c b/src/misc/objres.c
index e7a299ba1a..5ff390901f 100644
--- a/src/misc/objres.c
+++ b/src/misc/objres.c
@@ -46,13 +46,13 @@ static struct vlc_res **vlc_obj_res(vlc_object_t *obj)
 
 void *vlc_objres_new(size_t size, void (*release)(void *))
 {
-    if (unlikely(size > SIZE_MAX - sizeof (struct vlc_res)))
+    if (unlikely(add_overflow(sizeof (struct vlc_res), size, &size)))
     {
         errno = ENOMEM;
         return NULL;
     }
 
-    struct vlc_res *res = malloc(sizeof (*res) + size);
+    struct vlc_res *res = malloc(size);
     if (unlikely(res == NULL))
         return NULL;
 



More information about the vlc-commits mailing list