diff --git a/src/test/app/HostFuncImpl_test.cpp b/src/test/app/HostFuncImpl_test.cpp index dbcf9266fd..32379495dc 100644 --- a/src/test/app/HostFuncImpl_test.cpp +++ b/src/test/app/HostFuncImpl_test.cpp @@ -2252,6 +2252,12 @@ struct HostFuncImpl_test : public beast::unit_test::suite auto const result = hfs.floatSet(10, -1, 0); BEAST_EXPECT(result) && BEAST_EXPECT(*result == float1); } + + { + auto const result = hfs.floatSet(1, Number::maxExponent + normalExp + 1, 0); + BEAST_EXPECT(!result) && + BEAST_EXPECT(result.error() == HostFunctionError::FLOAT_COMPUTATION_ERROR); + } } void diff --git a/src/xrpld/app/wasm/detail/HostFuncImplFloat.cpp b/src/xrpld/app/wasm/detail/HostFuncImplFloat.cpp index f66e01d115..7e1b0382b1 100644 --- a/src/xrpld/app/wasm/detail/HostFuncImplFloat.cpp +++ b/src/xrpld/app/wasm/detail/HostFuncImplFloat.cpp @@ -221,6 +221,7 @@ floatFromIntImpl(int64_t x, int32_t mode) // LCOV_EXCL_START catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); // LCOV_EXCL_STOP @@ -242,6 +243,7 @@ floatFromUintImpl(uint64_t x, int32_t mode) // LCOV_EXCL_START catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); // LCOV_EXCL_STOP @@ -262,6 +264,7 @@ floatSetImpl(int64_t mantissa, int32_t exponent, int32_t mode) } catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } @@ -284,6 +287,7 @@ floatCompareImpl(Slice const& x, Slice const& y) // LCOV_EXCL_START catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); // LCOV_EXCL_STOP @@ -311,6 +315,7 @@ floatAddImpl(Slice const& x, Slice const& y, int32_t mode) // LCOV_EXCL_START catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); // LCOV_EXCL_STOP @@ -337,6 +342,7 @@ floatSubtractImpl(Slice const& x, Slice const& y, int32_t mode) // LCOV_EXCL_START catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); // LCOV_EXCL_STOP @@ -363,6 +369,7 @@ floatMultiplyImpl(Slice const& x, Slice const& y, int32_t mode) // LCOV_EXCL_START catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); // LCOV_EXCL_STOP @@ -388,6 +395,7 @@ floatDivideImpl(Slice const& x, Slice const& y, int32_t mode) } catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } @@ -415,6 +423,7 @@ floatRootImpl(Slice const& x, int32_t n, int32_t mode) // LCOV_EXCL_START catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); // LCOV_EXCL_STOP @@ -445,6 +454,7 @@ floatPowerImpl(Slice const& x, int32_t n, int32_t mode) // LCOV_EXCL_START catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); // LCOV_EXCL_STOP @@ -470,6 +480,7 @@ floatLogImpl(Slice const& x, int32_t mode) // LCOV_EXCL_START catch (...) { + return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); } return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); // LCOV_EXCL_STOP