summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2024-08-21 18:14:33 +0000
committerFedja Beader <fedja@protonmail.ch>2024-08-21 18:14:33 +0000
commit2f932e192e18a5efcd12b600337726b534f759a3 (patch)
tree984e98ffc7c4656e02d9cd26ebe836b23cb83e27 /src
parent59b7980cce1e171a8213390e81b8538a3661ada7 (diff)
downloadplus-2f932e192e18a5efcd12b600337726b534f759a3.tar.gz
plus-2f932e192e18a5efcd12b600337726b534f759a3.tar.bz2
plus-2f932e192e18a5efcd12b600337726b534f759a3.tar.xz
plus-2f932e192e18a5efcd12b600337726b534f759a3.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/net/eathena/skillrecv.cpp8
1 files changed, 6 insertions, 2 deletions
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 + ".";