[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.
This commit is contained in:
Alex King 2023-01-24 17:57:12 -05:00 committed by GitHub
parent bf39a0540c
commit 2b0c778ad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,10 +122,20 @@ public:
}
for (int spell_id = 2; spell_id < SPDAT_RECORDS; ++spell_id) {
if (spells[spell_id].player_1[0] == '\0')
if (!IsValidSpell(spell_id)) {
continue;
if (spells[spell_id].target_type != ST_Target && spells[spell_id].cast_restriction != 0) // watch
}
if (spells[spell_id].player_1[0] == '\0') {
continue;
}
if (
spells[spell_id].target_type != ST_Target &&
spells[spell_id].cast_restriction != 0
) {
continue;
}
auto target_type = BCEnum::TT_None;
switch (spells[spell_id].target_type) {