From 3f55152ca093edd90eba6cd2c979db0f32468900 Mon Sep 17 00:00:00 2001
From: Pierre-Emmanuel Viel
Date: Wed, 12 Aug 2020 23:07:35 +0200
Subject: [PATCH] Add debug assert to check in FLANN the vectors size is
multiple of the architecture word size
---
modules/flann/include/opencv2/flann/dist.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/modules/flann/include/opencv2/flann/dist.h b/modules/flann/include/opencv2/flann/dist.h
index e41b994d7e..b5a1f22532 100644
--- a/modules/flann/include/opencv2/flann/dist.h
+++ b/modules/flann/include/opencv2/flann/dist.h
@@ -683,6 +683,8 @@ struct Hamming2
template
ResultType operator()(const Iterator1 a, const Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
{
+ CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)");
+
#ifdef FLANN_PLATFORM_64_BIT
const uint64_t* pa = reinterpret_cast(a);
const uint64_t* pb = reinterpret_cast(b);
@@ -711,6 +713,8 @@ struct Hamming2
template
ResultType operator()(const Iterator1 a, ZeroIterator b, size_t size, ResultType /*worst_dist*/ = -1) const
{
+ CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)");
+
(void)b;
#ifdef FLANN_PLATFORM_64_BIT
const uint64_t* pa = reinterpret_cast(a);