From d114e665be22220f7379aa6cd45f7140c951a8a8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Sep 2026 17:21:13 +0000 Subject: [PATCH] fix: guard the group-loot division by zero OnLootMoney counts group members within loot reward distance, then divides gold by that count with no guard. If no member passes the distance check the count stays 0 and the division raises SIGFPE, taking worldserver down. The looter normally counts themselves so this is a latent rather than live bug, but the guard is free. Also hoists the LootMultiplier check above the member loop, which skips the whole walk when the module is configured off, and drops the now-redundant second test in the solo branch. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_019vTNrJGsprcjdjjjDJD5ZM --- src/mod_guildfunds_loot.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mod_guildfunds_loot.cpp b/src/mod_guildfunds_loot.cpp index c674e48..2572d83 100644 --- a/src/mod_guildfunds_loot.cpp +++ b/src/mod_guildfunds_loot.cpp @@ -5,6 +5,9 @@ void GuildFunds::OnLootMoney(Player* player, uint32 gold) { + if (LootMultiplier < 1) + return; + if (Group* group = player->GetGroup()) { uint32 membersInRange = 0; @@ -17,7 +20,10 @@ void GuildFunds::OnLootMoney(Player* player, uint32 gold) } } - if (LootMultiplier < 1) + // Guard the division. In practice the looter counts themselves, but a group whose + // members all fail the distance check would divide by zero and take worldserver + // down with SIGFPE. + if (!membersInRange) return; uint32 money = (gold / membersInRange) * LootMultiplier / 100; @@ -49,7 +55,7 @@ void GuildFunds::OnLootMoney(Player* player, uint32 gold) { uint32 money = gold * LootMultiplier / 100; - if (money < 1 || LootMultiplier < 1) + if (money < 1) return; guild->HandleMemberDepositMoney(player->GetSession(), money); -- 2.49.1