mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix UBSan report when trying to convert infinite floating point number to integer
This commit is contained in:
parent
7986dbdfc7
commit
22954cc123
@ -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
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
SET max_threads = nan; -- { serverError 70 }
|
Loading…
Reference in New Issue
Block a user