mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 06:42:12 +00:00
Correct two overflows in PInt ctor
This commit is contained in:
parent
91f8f5b556
commit
17f04c5043
1 changed files with 2 additions and 2 deletions
|
@ -501,7 +501,7 @@ PInt::PInt(unsigned int size, bool unsign, bool compatible)
|
|||
MemberOnly = (size < 4);
|
||||
if (!unsign)
|
||||
{
|
||||
int maxval = (1 << ((8 * size) - 1)) - 1;
|
||||
int maxval = (1u << ((8 * size) - 1)) - 1; // compute as unsigned to prevent overflow before -1
|
||||
int minval = -maxval - 1;
|
||||
Symbols.AddSymbol(new PSymbolConstNumeric(NAME_Min, this, minval));
|
||||
Symbols.AddSymbol(new PSymbolConstNumeric(NAME_Max, this, maxval));
|
||||
|
@ -509,7 +509,7 @@ PInt::PInt(unsigned int size, bool unsign, bool compatible)
|
|||
else
|
||||
{
|
||||
Symbols.AddSymbol(new PSymbolConstNumeric(NAME_Min, this, 0u));
|
||||
Symbols.AddSymbol(new PSymbolConstNumeric(NAME_Max, this, (1u << (8 * size)) - 1));
|
||||
Symbols.AddSymbol(new PSymbolConstNumeric(NAME_Max, this, (1u << ((8 * size) - 1))));
|
||||
}
|
||||
SetOps();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue