mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1202556 - Detect underflow in TimeStamp addition/subtraction operators; r=froydnj
This commit is contained in:
parent
b71f4ee5fd
commit
557a21eb5d
@ -504,13 +504,27 @@ public:
|
||||
TimeStamp& operator+=(const TimeDuration& aOther)
|
||||
{
|
||||
MOZ_ASSERT(!IsNull(), "Cannot compute with a null value");
|
||||
mValue += aOther.mValue;
|
||||
TimeStampValue value = mValue + aOther.mValue;
|
||||
// Check for underflow.
|
||||
// (We don't check for overflow because it's not obvious what the error
|
||||
// behavior should be in that case.)
|
||||
if (aOther.mValue < 0 && value > mValue) {
|
||||
value = 0;
|
||||
}
|
||||
mValue = value;
|
||||
return *this;
|
||||
}
|
||||
TimeStamp& operator-=(const TimeDuration& aOther)
|
||||
{
|
||||
MOZ_ASSERT(!IsNull(), "Cannot compute with a null value");
|
||||
mValue -= aOther.mValue;
|
||||
TimeStampValue value = mValue - aOther.mValue;
|
||||
// Check for underflow.
|
||||
// (We don't check for overflow because it's not obvious what the error
|
||||
// behavior should be in that case.)
|
||||
if (aOther.mValue > 0 && value > mValue) {
|
||||
value = 0;
|
||||
}
|
||||
mValue = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user