From d6654d906c1ae66590b6d600458a91f1ee923de5 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 28 Jul 2017 22:15:47 +0200 Subject: [PATCH] opj_int_ceildiv(): fix int32 overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2494. Credit to OSS Fuzz --- src/lib/openjp2/opj_intmath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/openjp2/opj_intmath.h b/src/lib/openjp2/opj_intmath.h index 03a446f1..64c87ed9 100644 --- a/src/lib/openjp2/opj_intmath.h +++ b/src/lib/openjp2/opj_intmath.h @@ -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); } /**