Core/AI: Fix uninitialized values and array overflows in SAI

Proper initialize POD struct members to 0 in SMART_ACTION_CREATE_TIMED_EVENT action type.
Fix array overflows and access uninitialized values in SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST, SMART_ACTION_RANDOM_PHASE and SMART_ACTION_RANDOM_EMOTE .

Valgrind log for SMART_ACTION_RANDOM_PHASE case:
 Conditional jump or move depends on uninitialised value(s)
   at : SmartScript::UpdateTimer(SmartScriptHolder&, unsigned int) (SmartScript.cpp:3086)
   by : SmartScript::OnUpdate(unsigned int) (SmartScript.cpp:3176)
   by : SmartAI::UpdateAI(unsigned int) (SmartAI.cpp:335)
   by : Creature::Update(unsigned int) (Creature.cpp:542)
   by : TempSummon::Update(unsigned int) (TemporarySummon.cpp:47)

 Uninitialised value was created by a stack allocation
   at : SmartScript::ProcessAction(SmartScriptHolder&, Unit*, unsigned int, unsigned int, bool, SpellInfo const*, GameObject*) (SmartScript.cpp:143)
This commit is contained in:
jackpoz committed 2013-09-24 23:33:28 +02:00
1 parent 4498ac0062
commit ec3832c2c1
2 files changed
+19 -7

No files matched your search

@@ -1288,7 +1288,7 @@ enum SmartCastFlags
struct SmartScriptHolder
{
SmartScriptHolder() : entryOrGuid(0), source_type(SMART_SCRIPT_TYPE_CREATURE)
, event_id(0), link(0), timer(0), active(false), runOnce(false)
, event_id(0), link(0), event(), action(), target(), timer(0), active(false), runOnce(false)
, enableTimed(false) {}
int32 entryOrGuid;