From c3400603d020f7ab134977f82723d3bbe3dc6f20 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 23 Jun 2025 15:42:23 +0300 Subject: [PATCH] Fixed out-of-bound access to function table in cv::norm for HORM_HAMING. --- modules/core/src/norm.dispatch.cpp | 2 +- modules/core/src/norm.simd.hpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/core/src/norm.dispatch.cpp b/modules/core/src/norm.dispatch.cpp index 6999e55cdf..a20eaf0824 100644 --- a/modules/core/src/norm.dispatch.cpp +++ b/modules/core/src/norm.dispatch.cpp @@ -316,7 +316,7 @@ double norm( InputArray _src, int normType, InputArray _mask ) } NormFunc func = getNormFunc(normType >> 1, depth == CV_16F ? CV_32F : depth); - CV_Assert( func != 0 ); + CV_Assert( (normType >> 1) >= 3 || func != 0 ); if( src.isContinuous() && mask.empty() ) { diff --git a/modules/core/src/norm.simd.hpp b/modules/core/src/norm.simd.hpp index 68bd21258e..1e94fff719 100644 --- a/modules/core/src/norm.simd.hpp +++ b/modules/core/src/norm.simd.hpp @@ -1324,6 +1324,8 @@ NormFunc getNormFunc(int normType, int depth) } }; + if (normType >= 3 || normType < 0) return nullptr; + return normTab[normType][depth]; }