1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Add CV_DISABLE_UBSAN to disable undefined behavior sanitizer

Also fix code here and there that triggered the fuzzer.
This commit is contained in:
Vincent Rabaud
2026-05-06 16:56:03 +02:00
parent 30fffe2fa0
commit 504899d433
4 changed files with 11 additions and 1 deletions
+7 -1
View File
@@ -684,7 +684,7 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType)
#endif
/****************************************************************************************\
* Thread sanitizer *
* Sanitizers *
\****************************************************************************************/
#ifndef CV_THREAD_SANITIZER
# if defined(__has_feature)
@@ -694,6 +694,12 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType)
# endif
#endif
#if defined(__clang__) || defined(__GNUC__)
#define CV_DISABLE_UBSAN __attribute__((no_sanitize("undefined")))
#else
#define CV_DISABLE_UBSAN
#endif
/****************************************************************************************\
* exchange-add operation for atomic operations on reference counters *
\****************************************************************************************/
@@ -361,6 +361,7 @@ CV_INLINE int cvRound( int value )
}
/** @overload */
CV_DISABLE_UBSAN
CV_INLINE int cvFloor( float value )
{
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \