From 2f932e192e18a5efcd12b600337726b534f759a3 Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Wed, 21 Aug 2024 18:14:33 +0000 Subject: Fix skill fail packet handling causing nullptr crash when switching characters How to reproduce: spam emote then quickly switch char Thread 1 "manaplus" received signal SIGSEGV, Segmentation fault. SkillDialog::getSkill (this=0x0, id=id@entry=1) at gui/windows/skilldialog.cpp:805 0 SkillDialog::getSkill (this=0x0, id=id@entry=1) at gui/windows/skilldialog.cpp:805 1 EAthena::SkillRecv::processSkillFailed (msg=...) at net/eathena/skillrecv.cpp:302 ... **** mana/plus!92 --- src/net/eathena/skillrecv.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/net/eathena/skillrecv.cpp b/src/net/eathena/skillrecv.cpp index 3f3e8efb1..dc24b15b4 100644 --- a/src/net/eathena/skillrecv.cpp +++ b/src/net/eathena/skillrecv.cpp @@ -298,7 +298,9 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) localPlayer->stopAdvert(); } - const SkillInfo *const info = skillDialog->getSkill(bskill); + const SkillInfo *const info = skillDialog + ? skillDialog->getSkill(bskill) + : nullptr; if (info != nullptr) { txt = info->errorText; @@ -311,7 +313,9 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) } else { - const SkillInfo *const info = skillDialog->getSkill(skillId); + const SkillInfo *const info = skillDialog + ? skillDialog->getSkill(skillId) + : nullptr; if (info != nullptr) { txt = info->errorText + "."; -- cgit v1.2.3-70-g09d2