Fixed out-of-bound access to function table in cv::norm for HORM_HAMING.

This commit is contained in:
Alexander Smorkalov 2025-06-23 15:42:23 +03:00
parent 4629299163
commit c3400603d0
2 changed files with 3 additions and 1 deletions

View File

@ -316,7 +316,7 @@ double norm( InputArray _src, int normType, InputArray _mask )
} }
NormFunc func = getNormFunc(normType >> 1, depth == CV_16F ? CV_32F : depth); 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() ) if( src.isContinuous() && mask.empty() )
{ {

View File

@ -1324,6 +1324,8 @@ NormFunc getNormFunc(int normType, int depth)
} }
}; };
if (normType >= 3 || normType < 0) return nullptr;
return normTab[normType][depth]; return normTab[normType][depth];
} }