]> granicus.if.org Git - openjpeg/commitdiff
opj_int_ceildiv(): fix int32 overflow. Fixes https://bugs.chromium.org/p/oss-fuzz...
authorEven Rouault <even.rouault@spatialys.com>
Fri, 28 Jul 2017 20:15:47 +0000 (22:15 +0200)
committerEven Rouault <even.rouault@spatialys.com>
Fri, 28 Jul 2017 20:15:47 +0000 (22:15 +0200)
src/lib/openjp2/opj_intmath.h

index 03a446f1ce3845fb6ffd184800d6a5c432934cdb..64c87ed96c3a0c62756d7783d544739185924b93 100644 (file)
@@ -129,7 +129,7 @@ Divide an integer and round upwards
 static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b)
 {
     assert(b);
-    return (a + b - 1) / b;
+    return (OPJ_INT32)(((OPJ_INT64)a + b - 1) / b);
 }
 
 /**