mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 22:15:52 +00:00
Add check to prevent negative zero.
We want a canonical encoding for zero which is 0x4000000000000000 i.e. "positive zero". So we want to disallow the alternative encoding 0x0000000000000000 i.e. "negative zero".
This commit is contained in:
@@ -570,12 +570,14 @@ STAmount* STAmount::construct(SerializerIterator& sit, SField::ref name)
|
||||
{ // native
|
||||
if ((value & cPosNative) != 0)
|
||||
return new STAmount(name, value & ~cPosNative, false); // positive
|
||||
else if (value == 0)
|
||||
throw std::runtime_error("negative zero is not canonical");
|
||||
return new STAmount(name, value, true); // negative
|
||||
}
|
||||
|
||||
uint160 uCurrencyID = sit.get160();
|
||||
if (!uCurrencyID)
|
||||
throw std::runtime_error("invalid native currency");
|
||||
throw std::runtime_error("invalid non-native currency");
|
||||
|
||||
uint160 uIssuerID = sit.get160();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user