mirror of https://github.com/OpenRCT2/OpenRCT2.git
Check finance_payment for int overflows
This commit is contained in:
parent
2235390ce2
commit
3e621d75f6
|
@ -73,9 +73,16 @@ uint8 gCommandExpenditureType;
|
|||
void finance_payment(money32 amount, rct_expenditure_type type)
|
||||
{
|
||||
money32 cur_money = DECRYPT_MONEY(gCashEncrypted);
|
||||
money32 new_money = cur_money - amount;
|
||||
money32 new_money;
|
||||
|
||||
//overflow check
|
||||
if (amount < 0 && cur_money >= INT_MAX + amount)
|
||||
new_money = INT_MAX;
|
||||
else if (amount >= 0 && cur_money < INT_MIN + amount)
|
||||
new_money = INT_MIN;
|
||||
else
|
||||
new_money = cur_money - amount;
|
||||
|
||||
gCashEncrypted = ENCRYPT_MONEY(new_money);
|
||||
gExpenditureTable[type] -= amount;
|
||||
if (dword_988E60[type] & 1)
|
||||
|
|
|
@ -54,7 +54,7 @@ extern "C" {
|
|||
// This define specifies which version of network stream current build uses.
|
||||
// It is used for making sure only compatible builds get connected, even within
|
||||
// single OpenRCT2 version.
|
||||
#define NETWORK_STREAM_VERSION "28"
|
||||
#define NETWORK_STREAM_VERSION "29"
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue