mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix underflow issue for XRP:
In some cases multiplying or dividing STAmounts gave incorrect results. This happens when: 1) The result should be rounded up 2) The STAmount represents a native value (XRP) 3) The rounded up value was less than one drop In this case, the result was zero, instead of one drop. This could cause funded offers to be removed as unfunded.
This commit is contained in:
@@ -402,6 +402,7 @@ inline bool isXRP(STAmount const& amount)
|
||||
}
|
||||
|
||||
extern LocalValue<bool> stAmountCalcSwitchover;
|
||||
extern LocalValue<bool> stAmountCalcSwitchover2;
|
||||
|
||||
/** RAII class to set and restore the STAmount calc switchover.*/
|
||||
class STAmountSO
|
||||
@@ -409,20 +410,27 @@ class STAmountSO
|
||||
public:
|
||||
explicit STAmountSO(NetClock::time_point const closeTime)
|
||||
: saved_(*stAmountCalcSwitchover)
|
||||
, saved2_(*stAmountCalcSwitchover2)
|
||||
{
|
||||
*stAmountCalcSwitchover = closeTime > soTime;
|
||||
*stAmountCalcSwitchover2 = closeTime > soTime2;
|
||||
}
|
||||
|
||||
~STAmountSO()
|
||||
{
|
||||
*stAmountCalcSwitchover = saved_;
|
||||
*stAmountCalcSwitchover2 = saved2_;
|
||||
}
|
||||
|
||||
// Mon Dec 28, 2015 10:00:00am PST
|
||||
static NetClock::time_point const soTime;
|
||||
|
||||
// Mon Mar 28, 2015 10:00:00am PST
|
||||
static NetClock::time_point const soTime2;
|
||||
|
||||
private:
|
||||
bool saved_;
|
||||
bool saved2_;
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
Reference in New Issue
Block a user