mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
core: fix UBSAN in softfloat
This commit is contained in:
parent
7ce9428e96
commit
ed9bca969c
@ -2065,13 +2065,17 @@ static int_fast64_t f64_to_i64(float64_t a, uint_fast8_t roundingMode, bool exac
|
|||||||
if (exp) sig |= UINT64_C(0x0010000000000000);
|
if (exp) sig |= UINT64_C(0x0010000000000000);
|
||||||
shiftDist = 0x433 - exp;
|
shiftDist = 0x433 - exp;
|
||||||
if (shiftDist <= 0) {
|
if (shiftDist <= 0) {
|
||||||
uint_fast64_t z = sig << -shiftDist;
|
bool isValid = shiftDist >= -11;
|
||||||
if ((shiftDist < -11) || (z & UINT64_C(0x8000000000000000)))
|
if (isValid)
|
||||||
{
|
{
|
||||||
raiseFlags(flag_invalid);
|
uint_fast64_t z = sig << -shiftDist;
|
||||||
return sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
if (0 == (z & UINT64_C(0x8000000000000000)))
|
||||||
|
{
|
||||||
|
return sign ? -(int_fast64_t)z : (int_fast64_t)z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sign ? -(int_fast64_t)z : (int_fast64_t)z;
|
raiseFlags(flag_invalid);
|
||||||
|
return sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (shiftDist < 64)
|
if (shiftDist < 64)
|
||||||
|
Loading…
Reference in New Issue
Block a user