Core/Misc: Fix issues reported by static analysis
Coverity defect IDs: 1227510, 1227434, 1023036, 1062426, 1062425, 1062424, 1062423, 1062422
This commit is contained in:
1 parent
5f77145f49
commit
d23538ce56
4 files changed
+49
-18
No files matched your search
@@ -5880,7 +5880,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
if (dummySpell->SpellIconID == 2218)
|
||||
{
|
||||
// Proc only from Abolish desease on self cast
|
||||
if (procSpell->Id != 552 || victim != this || !roll_chance_i(triggerAmount))
|
||||
if (!procSpell || procSpell->Id != 552 || victim != this || !roll_chance_i(triggerAmount))
|
||||
return false;
|
||||
triggered_spell_id = 64136;
|
||||
target = this;
|
||||
@@ -14173,6 +14173,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
uint32 Id = i->aura->GetId();
|
||||
|
||||
AuraApplication* aurApp = i->aura->GetApplicationOfTarget(GetGUID());
|
||||
ASSERT(aurApp);
|
||||
|
||||
bool prepare = i->aura->CallScriptPrepareProcHandlers(aurApp, eventInfo);
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
Map::PlayerList const &PlayerList = map->GetPlayers();
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
{
|
||||
if (i->GetSource() && i->GetSource()->IsAlive() && me->HasInArc(float(diff/20000*M_PI*2), i->GetSource()) && me->IsWithinDist(i->GetSource(), SPOUT_DIST) && !i->GetSource()->IsInWater())
|
||||
if (i->GetSource() && i->GetSource()->IsAlive() && me->HasInArc(diff/20000.f*float(M_PI)*2.f, i->GetSource()) && me->IsWithinDist(i->GetSource(), SPOUT_DIST) && !i->GetSource()->IsInWater())
|
||||
DoCast(i->GetSource(), SPELL_SPOUT, true); // only knock back players in arc, in 100yards, not in water
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,9 @@ typedef struct
|
||||
map_id *map_ids;
|
||||
uint16 *areas;
|
||||
uint16 *LiqType;
|
||||
char output_path[128] = ".";
|
||||
char input_path[128] = ".";
|
||||
#define MAX_PATH_LENGTH 128
|
||||
char output_path[MAX_PATH_LENGTH] = ".";
|
||||
char input_path[MAX_PATH_LENGTH] = ".";
|
||||
uint32 maxAreaId = 0;
|
||||
|
||||
// **************************************************
|
||||
@@ -143,11 +144,11 @@ void Usage(char* prg)
|
||||
printf(
|
||||
"Usage:\n"\
|
||||
"%s -[var] [value]\n"\
|
||||
"-i set input path\n"\
|
||||
"-o set output path\n"\
|
||||
"-i set input path (max %d characters)\n"\
|
||||
"-o set output path (max %d characters)\n"\
|
||||
"-e extract only MAP(1)/DBC(2) - standard: both(3)\n"\
|
||||
"-f height stored as int (less map size but lost some accuracy) 1 by default\n"\
|
||||
"Example: %s -f 0 -i \"c:\\games\\game\"", prg, prg);
|
||||
"Example: %s -f 0 -i \"c:\\games\\game\"", prg, MAX_PATH_LENGTH - 1, MAX_PATH_LENGTH - 1, prg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -166,14 +167,20 @@ void HandleArgs(int argc, char * arg[])
|
||||
switch(arg[c][1])
|
||||
{
|
||||
case 'i':
|
||||
if(c + 1 < argc) // all ok
|
||||
strcpy(input_path, arg[(c++) + 1]);
|
||||
if (c + 1 < argc && strlen(arg[c + 1]) < MAX_PATH_LENGTH) // all ok
|
||||
{
|
||||
strncpy(input_path, arg[c++ + 1], MAX_PATH_LENGTH);
|
||||
input_path[MAX_PATH_LENGTH - 1] = '\0';
|
||||
}
|
||||
else
|
||||
Usage(arg[0]);
|
||||
break;
|
||||
case 'o':
|
||||
if(c + 1 < argc) // all ok
|
||||
strcpy(output_path, arg[(c++) + 1]);
|
||||
if (c + 1 < argc && strlen(arg[c + 1]) < MAX_PATH_LENGTH) // all ok
|
||||
{
|
||||
strncpy(output_path, arg[c++ + 1], MAX_PATH_LENGTH);
|
||||
output_path[MAX_PATH_LENGTH - 1] = '\0';
|
||||
}
|
||||
else
|
||||
Usage(arg[0]);
|
||||
break;
|
||||
@@ -250,7 +257,17 @@ uint32 ReadMapDBC()
|
||||
for(uint32 x = 0; x < map_count; ++x)
|
||||
{
|
||||
map_ids[x].id = dbc.getRecord(x).getUInt(0);
|
||||
strcpy(map_ids[x].name, dbc.getRecord(x).getString(1));
|
||||
|
||||
const char* map_name = dbc.getRecord(x).getString(1);
|
||||
size_t max_map_name_length = sizeof(map_ids[x].name);
|
||||
if (strlen(map_name) >= max_map_name_length)
|
||||
{
|
||||
printf("Fatal error: Map name too long!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
strncpy(map_ids[x].name, map_name, max_map_name_length);
|
||||
map_ids[x].name[max_map_name_length - 1] = '\0';
|
||||
}
|
||||
printf("Done! (%u maps loaded)\n", (uint32)map_count);
|
||||
return map_count;
|
||||
|
||||
@@ -197,7 +197,7 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
for (uint32 i = 0; i < froot.nGroups; ++i)
|
||||
{
|
||||
char temp[1024];
|
||||
strcpy(temp, fname.c_str());
|
||||
strncpy(temp, fname.c_str(), 1024);
|
||||
temp[fname.length()-4] = 0;
|
||||
char groupFileName[1024];
|
||||
sprintf(groupFileName, "%s_%03u.wmo", temp, i);
|
||||
@@ -395,7 +395,9 @@ bool processArgv(int argc, char ** argv, const char *versionString)
|
||||
if((i+1)<argc)
|
||||
{
|
||||
hasInputPathParam = true;
|
||||
strcpy(input_path, argv[i+1]);
|
||||
strncpy(input_path, argv[i + 1], sizeof(input_path));
|
||||
input_path[sizeof(input_path) - 1] = '\0';
|
||||
|
||||
if (input_path[strlen(input_path) - 1] != '\\' && input_path[strlen(input_path) - 1] != '/')
|
||||
strcat(input_path, "/");
|
||||
++i;
|
||||
@@ -511,11 +513,22 @@ int main(int argc, char ** argv)
|
||||
map_ids=new map_id[map_count];
|
||||
for (unsigned int x=0;x<map_count;++x)
|
||||
{
|
||||
map_ids[x].id=dbc->getRecord (x).getUInt(0);
|
||||
strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
|
||||
printf("Map - %s\n",map_ids[x].name);
|
||||
}
|
||||
map_ids[x].id = dbc->getRecord(x).getUInt(0);
|
||||
|
||||
const char* map_name = dbc->getRecord(x).getString(1);
|
||||
size_t max_map_name_length = sizeof(map_ids[x].name);
|
||||
if (strlen(map_name) >= max_map_name_length)
|
||||
{
|
||||
delete dbc;
|
||||
delete[] map_ids;
|
||||
printf("FATAL ERROR: Map name too long.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
strncpy(map_ids[x].name, map_name, max_map_name_length);
|
||||
map_ids[x].name[max_map_name_length - 1] = '\0';
|
||||
printf("Map - %s\n", map_ids[x].name);
|
||||
}
|
||||
|
||||
delete dbc;
|
||||
ParsMapFiles();
|
||||
|
||||
Reference in new issue
Block a user