Core/Misc: Fix static analysis issues

Fix some static analysis issues reported by Coverity
This commit is contained in:
jackpoz
2015-01-18 18:30:34 +01:00
parent dfa0f2a253
commit 5dfd07fa4f
5 changed files with 12 additions and 2 deletions

View File

@@ -1316,7 +1316,10 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond)
}
if (!assigned)
{
delete sharedList;
break;
}
}
sharedList->push_back(cond);
break;

View File

@@ -631,7 +631,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
// Rage from Damage made (only from direct weapon damage)
if (cleanDamage && damagetype == DIRECT_DAMAGE && this != victim && getPowerType() == POWER_RAGE)
{
uint32 rage = uint32(GetAttackTime(cleanDamage->attackType) / 1000 * 8.125f);
uint32 rage = uint32(GetAttackTime(cleanDamage->attackType) / 1000.f * 8.125f);
switch (cleanDamage->attackType)
{
case OFF_ATTACK:

View File

@@ -327,6 +327,9 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint32 effMask, WorldObject* own
else
casterGUID = caster->GetGUID();
// at this point of Aura::Create() there MUST be a valid caster
ASSERT(caster);
// check if aura can be owned by owner
if (owner->isType(TYPEMASK_UNIT))
if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld())

View File

@@ -2292,7 +2292,10 @@ namespace Trinity
va_end(ap);
}
else
std::strcpy(strBuffer, text);
{
std::strncpy(strBuffer, text, BufferSize);
strBuffer[BufferSize - 1] = '\0';
}
do_helper(dataList, strBuffer);
}

View File

@@ -513,6 +513,7 @@ char* DB2DatabaseLoader::Load(const char* format, int32 preparedStatement, uint3
{
LocalizedString** slot = (LocalizedString**)(&dataValue[offset]);
*slot = (LocalizedString*)(&stringHolders[stringHoldersRecordPoolSize * rec + stringHolderSize * stringFieldNumInRecord]);
ASSERT(*slot);
// Value in database in main table field must be for enUS locale
if (char* str = AddLocaleString(*slot, LOCALE_enUS, fields[f].GetString()))