mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 13:05:53 +00:00
Add safe_cast (RIPD-1702):
This change ensures that no overflow can occur when casting between enums and integral types.
This commit is contained in:
committed by
Nik Bougalis
parent
494724578a
commit
148bbf4e8f
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/basics/safe_cast.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/protocol/SystemParameters.h>
|
||||
#include <ripple/protocol/STAmount.h>
|
||||
@@ -246,13 +247,13 @@ STAmount::STAmount (Issue const& issue,
|
||||
|
||||
STAmount::STAmount (Issue const& issue,
|
||||
std::uint32_t mantissa, int exponent, bool negative)
|
||||
: STAmount (issue, static_cast<std::uint64_t>(mantissa), exponent, negative)
|
||||
: STAmount (issue, safe_cast<std::uint64_t>(mantissa), exponent, negative)
|
||||
{
|
||||
}
|
||||
|
||||
STAmount::STAmount (Issue const& issue,
|
||||
int mantissa, int exponent)
|
||||
: STAmount (issue, static_cast<std::int64_t>(mantissa), exponent)
|
||||
: STAmount (issue, safe_cast<std::int64_t>(mantissa), exponent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user