mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Core/Misc: Fix out of bounds access on startup
Fix out of bound access on startup trying to access SpellEffects with ID greater than max allowed/known. Reported by AddressSanitizer .
This commit is contained in:
@@ -2617,6 +2617,22 @@ void SpellMgr::LoadSpellInfoStore()
|
||||
if (SpellEntry const* spellEntry = sSpellStore.LookupEntry(i))
|
||||
mSpellInfoMap[i] = new SpellInfo(spellEntry, effectsBySpell[i].effects);
|
||||
|
||||
for (uint32 spellIndex = 0; spellIndex < GetSpellInfoStoreSize(); ++spellIndex)
|
||||
{
|
||||
if (!mSpellInfoMap[spellIndex])
|
||||
continue;
|
||||
|
||||
for (uint32 effectIndex = 0; effectIndex < MAX_SPELL_EFFECTS; ++effectIndex)
|
||||
{
|
||||
if (mSpellInfoMap[spellIndex]->Effects[effectIndex].Effect >= TOTAL_SPELL_EFFECTS)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Spell (Entry: %u) has `Effect` '%u' greater than max allowed value '%u', removing", spellIndex, mSpellInfoMap[spellIndex]->Effects[effectIndex].Effect, (TOTAL_SPELL_EFFECTS - 1));
|
||||
mSpellInfoMap[spellIndex]->Effects[effectIndex].Effect = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded SpellInfo store in %u ms", GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user