Skip to content

Commit 2b0c778

Browse files
authored
[Bug Fix] Fix nullptr spell in BCSpells::Load() (#2790)
* [Bug Fix] Fix nullptr spell in BCSpells::Load() # Notes - Fix possible `nullptr` where we didn't check if spell was valid before using it. * Cleanup.
1 parent bf39a05 commit 2b0c778

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

zone/bot_command.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,20 @@ class BCSpells
122122
}
123123

124124
for (int spell_id = 2; spell_id < SPDAT_RECORDS; ++spell_id) {
125-
if (spells[spell_id].player_1[0] == '\0')
125+
if (!IsValidSpell(spell_id)) {
126126
continue;
127-
if (spells[spell_id].target_type != ST_Target && spells[spell_id].cast_restriction != 0) // watch
127+
}
128+
129+
if (spells[spell_id].player_1[0] == '\0') {
130+
continue;
131+
}
132+
133+
if (
134+
spells[spell_id].target_type != ST_Target &&
135+
spells[spell_id].cast_restriction != 0
136+
) {
128137
continue;
138+
}
129139

130140
auto target_type = BCEnum::TT_None;
131141
switch (spells[spell_id].target_type) {

0 commit comments

Comments
 (0)