From 542b3e8a64a1516657ec84fd9b2acaaa2baf6440 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Mon, 13 Dec 2021 23:43:49 +0100 Subject: [PATCH] Fix harmless signed integer overflow. When computing: t1 = (bayer[1] + bayer[bayer_step] + bayer[bayer_step+2] + bayer[bayer_step*2+1])*G2Y; there is a T (unsigned short or char) multiplied by an int which can overflow. Then again, it is stored to t1 which is unsigned so the overflow disappears. Keeping all unsigned is safer. --- modules/imgproc/src/demosaicing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/src/demosaicing.cpp b/modules/imgproc/src/demosaicing.cpp index 03bc781046..27dfc1520c 100644 --- a/modules/imgproc/src/demosaicing.cpp +++ b/modules/imgproc/src/demosaicing.cpp @@ -603,7 +603,7 @@ public: virtual void operator ()(const Range& range) const CV_OVERRIDE { SIMDInterpolator vecOp; - const int G2Y = 9617; + const unsigned G2Y = 9617; const int SHIFT = 14; const T* bayer0 = srcmat.ptr();