mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Avoid bigint_cast stack overflow
This commit is contained in:
parent
268b15f221
commit
615287ae75
@ -239,6 +239,13 @@ struct integer<Bits, Signed>::_impl
|
||||
template <class T>
|
||||
constexpr static void set_multiplier(integer<Bits, Signed> & self, T t) noexcept {
|
||||
constexpr uint64_t max_int = std::numeric_limits<uint64_t>::max();
|
||||
|
||||
/// Replacing nan to zero, and inf to max(T) to avoid stack overflow in bigint_cast
|
||||
if (isnan(t))
|
||||
t = 0;
|
||||
if (isinf(t))
|
||||
t = std::numeric_limits<T>::max();
|
||||
|
||||
const T alpha = t / max_int;
|
||||
|
||||
if (alpha <= max_int)
|
||||
|
Loading…
Reference in New Issue
Block a user