[vlc-commits] block: only do the size test when it's meaningful

Steve Lhomme git at videolan.org
Wed Jul 11 11:13:22 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jul 11 08:59:13 2018 +0200| [7a699a45da1e5f622a375cec405b98c3cc5715d3] | committer: Steve Lhomme

block: only do the size test when it's meaningful

If uintmax_t has the same size as size_t then it cannot be bigger than SIZE_MAX
ever.

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

 src/misc/block.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/misc/block.c b/src/misc/block.c
index 7d67138768..19e0c07109 100644
--- a/src/misc/block.c
+++ b/src/misc/block.c
@@ -387,12 +387,14 @@ block_t *block_File(int fd, bool write)
         return NULL;
     }
 
+//#if sizeof(uintmax_t) > sizeof(size_t)
     /* Prevent an integer overflow in mmap() and malloc() */
     if ((uintmax_t)st.st_size >= SIZE_MAX)
     {
         errno = ENOMEM;
         return NULL;
     }
+//#endif
     length = (size_t)st.st_size;
 
 #ifdef HAVE_MMAP



More information about the vlc-commits mailing list