Commit e175150f authored by chenguoping's avatar chenguoping

fix UBSAN

parent 8f5b5c74
......@@ -194,7 +194,8 @@ class binary_writer
}
else
{
if (static_cast<double>(static_cast<float>(j.m_value.number_float)) == j.m_value.number_float)
if (j.m_value.number_float < std::numeric_limits<float>::max() and
static_cast<double>(static_cast<float>(j.m_value.number_float)) == j.m_value.number_float)
{
oa->write_character(get_cbor_float_prefix(static_cast<float>(j.m_value.number_float)));
write_number(static_cast<float>(j.m_value.number_float));
......
......@@ -12143,7 +12143,8 @@ class binary_writer
}
else
{
if (static_cast<double>(static_cast<float>(j.m_value.number_float)) == j.m_value.number_float)
if (j.m_value.number_float < std::numeric_limits<float>::max() and
static_cast<double>(static_cast<float>(j.m_value.number_float)) == j.m_value.number_float)
{
oa->write_character(get_cbor_float_prefix(static_cast<float>(j.m_value.number_float)));
write_number(static_cast<float>(j.m_value.number_float));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment