Skip to content

Commit 3f55152

Browse files
committed
Add debug assert to check in FLANN the vectors size is multiple of the architecture word size
1 parent f3cebb3 commit 3f55152

File tree

1 file changed

+4
-0
lines changed
  • modules/flann/include/opencv2/flann

1 file changed

+4
-0
lines changed

modules/flann/include/opencv2/flann/dist.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,8 @@ struct Hamming2
683683
template <typename Iterator1, typename Iterator2>
684684
ResultType operator()(const Iterator1 a, const Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
685685
{
686+
CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)");
687+
686688
#ifdef FLANN_PLATFORM_64_BIT
687689
const uint64_t* pa = reinterpret_cast<const uint64_t*>(a);
688690
const uint64_t* pb = reinterpret_cast<const uint64_t*>(b);
@@ -711,6 +713,8 @@ struct Hamming2
711713
template <typename Iterator1>
712714
ResultType operator()(const Iterator1 a, ZeroIterator<unsigned char> b, size_t size, ResultType /*worst_dist*/ = -1) const
713715
{
716+
CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)");
717+
714718
(void)b;
715719
#ifdef FLANN_PLATFORM_64_BIT
716720
const uint64_t* pa = reinterpret_cast<const uint64_t*>(a);

0 commit comments

Comments
 (0)