mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-16 16:12:14 +11:00
🐛 fixed unsigned underflow when negative
This commit is contained in:
parent
6dad3ed0af
commit
2419641cd0
1 changed files with 1 additions and 2 deletions
|
|
@ -179,7 +179,6 @@ bool Bank::VerifyPassword(const std::string &name, const std::string_view &attem
|
||||||
Bank::users.if_contains(name, [&res, &attempt](const User &u) { res = (u.password == xxHashStringGen{}(attempt)); });
|
Bank::users.if_contains(name, [&res, &attempt](const User &u) { res = (u.password == xxHashStringGen{}(attempt)); });
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bank::ChangePassword(const std::string &name, const std::string &new_pass) noexcept
|
void Bank::ChangePassword(const std::string &name, const std::string &new_pass) noexcept
|
||||||
{
|
{
|
||||||
SET_CHANGES_ON;
|
SET_CHANGES_ON;
|
||||||
|
|
@ -211,7 +210,7 @@ BankResponse Bank::ImpactBal(const std::string &name, int64_t amount) noexcept
|
||||||
}
|
}
|
||||||
uint32_t bal;
|
uint32_t bal;
|
||||||
if (ValidUsername(name) && Bank::users.modify_if(name, [&bal, &amount](User &u) {
|
if (ValidUsername(name) && Bank::users.modify_if(name, [&bal, &amount](User &u) {
|
||||||
if (u.balance < (amount * -1)) { amount = -u.balance; };
|
if (u.balance < (amount * -1)) { amount = -int64_t(u.balance); };
|
||||||
bal = u.balance += amount;
|
bal = u.balance += amount;
|
||||||
#if MAX_LOG_SIZE > 0
|
#if MAX_LOG_SIZE > 0
|
||||||
u.log.AddTrans("Ω", (amount > 0), std::abs(amount), time(NULL));
|
u.log.AddTrans("Ω", (amount > 0), std::abs(amount), time(NULL));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue