Skip to content

Commit daf3fab

Browse files
committed
Merge pull request opencv#8877 from alalek:fix_integer_overflow
2 parents 0213b50 + e665be1 commit daf3fab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/photo/src/fast_nlmeans_denoising_opencl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ static bool ocl_calcAlmostDist2Weight(UMat & almostDist2Weight,
5252
FT almostDist2ActualDistMultiplier = (FT)(1 << almostTemplateWindowSizeSqBinShift) / templateWindowSizeSq;
5353

5454
const FT WEIGHT_THRESHOLD = 1e-3f;
55-
int maxDist = normType == NORM_L1 ? std::numeric_limits<ST>::max() * cn :
56-
std::numeric_limits<ST>::max() * std::numeric_limits<ST>::max() * cn;
55+
WT maxDist = normType == NORM_L1 ? (WT)std::numeric_limits<ST>::max() * cn :
56+
(WT)std::numeric_limits<ST>::max() * (WT)std::numeric_limits<ST>::max() * cn;
5757
int almostMaxDist = (int)(maxDist / almostDist2ActualDistMultiplier + 1);
5858
FT den[4];
5959
CV_Assert(hn > 0 && hn <= 4);

0 commit comments

Comments
 (0)