Fix UBSan report when trying to convert infinite floating point number to integer

This commit is contained in:
Alexey Milovidov 2020-11-04 19:48:36 +03:00
parent 7986dbdfc7
commit 22954cc123
3 changed files with 6 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include <Core/DecimalFunctions.h> #include <Core/DecimalFunctions.h>
#include <Core/Field.h> #include <Core/Field.h>
#include <common/demangle.h> #include <common/demangle.h>
#include <Common/NaNUtils.h>
class SipHash; class SipHash;
@ -142,6 +143,10 @@ public:
T operator() (const Float64 & x) const T operator() (const Float64 & x) const
{ {
if constexpr (!std::is_floating_point_v<T>)
if (!isFinite(x))
throw Exception("Cannot convert infinite value to integer type", ErrorCodes::CANNOT_CONVERT_TYPE);
if constexpr (std::is_same_v<Decimal256, T>) if constexpr (std::is_same_v<Decimal256, T>)
return Int256(x); return Int256(x);
else else

View File

@ -0,0 +1 @@
SET max_threads = nan; -- { serverError 70 }