Merge pull request #20966 from ZehMatt/fix-20964

Fix #20964: Crash when invalid network group id is used
This commit is contained in:
Matt 2023-11-11 23:48:48 +02:00 committed by GitHub
commit da1fa18523
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -14,6 +14,7 @@
- Fix: [#20737] Spent money in player window underflows when getting refunds.
- Fix: [#20778] [Plugin] Incorrect target api when executing custom actions.
- Fix: [#20807] Tertiary colour not copied with small scenery.
- Fix: [#20964] Crash when player connects to server with a group assigned that no longer exists.
0.4.6 (2023-09-03)
------------------------------------------------------------------------

View File

@ -2643,7 +2643,10 @@ void NetworkBase::ServerHandleAuth(NetworkConnection& connection, NetworkPacket&
if (connection.AuthStatus == NetworkAuth::Verified)
{
const NetworkGroup* group = GetGroupByID(GetGroupIDByHash(connection.Key.PublicKeyHash()));
passwordless = group->CanPerformAction(NetworkPermission::PasswordlessLogin);
if (group != nullptr)
{
passwordless = group->CanPerformAction(NetworkPermission::PasswordlessLogin);
}
}
if (gameversion != NetworkGetVersion())
{
@ -3649,6 +3652,11 @@ GameActions::Result NetworkModifyGroups(
case ModifyGroupType::SetName:
{
NetworkGroup* group = network.GetGroupByID(groupId);
if (group == nullptr)
{
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_RENAME_GROUP, STR_NONE);
}
const char* oldName = group->GetName().c_str();
if (strcmp(oldName, name.c_str()) == 0)