1
0
Fork 0

Nullify deleted pointers.

This commit is contained in:
archshift 2014-06-19 01:49:56 -07:00
parent 35a4aa419c
commit e8143de01b
35 changed files with 75 additions and 18 deletions

View File

@ -1765,6 +1765,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
if (!ChunkStay->AddChunks(2))
{
delete ChunkStay;
ChunkStay = NULL;
return 0;
}

View File

@ -1571,6 +1571,7 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType);
m_LuaState.LogStackTrace();
delete Ref;
Ref = NULL;
return false;
}

View File

@ -1467,6 +1467,7 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin)
a_Plugin->OnDisable();
}
delete a_Plugin;
a_Plugin = NULL;
}

View File

@ -295,9 +295,9 @@ cBlockArea::~cBlockArea()
void cBlockArea::Clear(void)
{
delete[] m_BlockTypes; m_BlockTypes = NULL;
delete[] m_BlockMetas; m_BlockMetas = NULL;
delete[] m_BlockLight; m_BlockLight = NULL;
delete[] m_BlockTypes; m_BlockTypes = NULL;
delete[] m_BlockMetas; m_BlockMetas = NULL;
delete[] m_BlockLight; m_BlockLight = NULL;
delete[] m_BlockSkyLight; m_BlockSkyLight = NULL;
m_Origin.Set(0, 0, 0);
m_Size.Set(0, 0, 0);
@ -1013,8 +1013,8 @@ void cBlockArea::RotateCCW(void)
} // for x
std::swap(m_BlockTypes, NewTypes);
std::swap(m_BlockMetas, NewMetas);
delete[] NewTypes;
delete[] NewMetas;
delete[] NewTypes; NewTypes = NULL;
delete[] NewMetas; NewMetas = NULL;
std::swap(m_Size.x, m_Size.z);
}
@ -1058,8 +1058,8 @@ void cBlockArea::RotateCW(void)
} // for x
std::swap(m_BlockTypes, NewTypes);
std::swap(m_BlockMetas, NewMetas);
delete[] NewTypes;
delete[] NewMetas;
delete[] NewTypes; NewTypes = NULL;
delete[] NewMetas; NewMetas = NULL;
std::swap(m_Size.x, m_Size.z);
}
@ -1206,7 +1206,7 @@ void cBlockArea::RotateCCWNoMeta(void)
} // for z
} // for x
std::swap(m_BlockTypes, NewTypes);
delete[] NewTypes;
delete[] NewTypes; NewTypes = NULL;
}
if (HasBlockMetas())
{
@ -1224,7 +1224,7 @@ void cBlockArea::RotateCCWNoMeta(void)
} // for z
} // for x
std::swap(m_BlockMetas, NewMetas);
delete[] NewMetas;
delete[] NewMetas; NewMetas = NULL;
}
std::swap(m_Size.x, m_Size.z);
}
@ -1251,7 +1251,7 @@ void cBlockArea::RotateCWNoMeta(void)
} // for x
} // for z
std::swap(m_BlockTypes, NewTypes);
delete[] NewTypes;
delete[] NewTypes; NewTypes = NULL;
}
if (HasBlockMetas())
{
@ -1269,7 +1269,7 @@ void cBlockArea::RotateCWNoMeta(void)
} // for x
} // for z
std::swap(m_BlockMetas, NewMetas);
delete[] NewMetas;
delete[] NewMetas; NewMetas = NULL;
}
std::swap(m_Size.x, m_Size.z);
}
@ -1658,6 +1658,7 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
if (m_BlockMetas == NULL)
{
delete[] m_BlockTypes;
m_BlockTypes = NULL;
return false;
}
}
@ -1667,7 +1668,9 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
if (m_BlockLight == NULL)
{
delete[] m_BlockMetas;
m_BlockMetas = NULL;
delete[] m_BlockTypes;
m_BlockTypes = NULL;
return false;
}
}
@ -1677,8 +1680,11 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
if (m_BlockSkyLight == NULL)
{
delete[] m_BlockLight;
m_BlockLight = NULL;
delete[] m_BlockMetas;
m_BlockMetas = NULL;
delete[] m_BlockTypes;
m_BlockTypes = NULL;
return false;
}
}

View File

@ -34,6 +34,7 @@ cBlockInfo::cBlockInfo()
cBlockInfo::~cBlockInfo()
{
delete m_Handler;
m_Handler = NULL;
}

View File

@ -165,6 +165,7 @@ cByteBuffer::~cByteBuffer()
{
CheckValid();
delete[] m_Buffer;
m_Buffer = NULL;
}

View File

@ -152,7 +152,9 @@ cChunk::~cChunk()
m_NeighborZP->m_NeighborZM = NULL;
}
delete m_WaterSimulatorData;
m_WaterSimulatorData = NULL;
delete m_LavaSimulatorData;
m_LavaSimulatorData = NULL;
}
@ -596,6 +598,7 @@ void cChunk::Tick(float a_Dt)
cEntity * ToDelete = *itr;
itr = m_Entities.erase(itr);
delete ToDelete;
ToDelete = NULL;
continue;
}
++itr;
@ -1417,6 +1420,7 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType,
BlockEntity->Destroy();
RemoveBlockEntity(BlockEntity);
delete BlockEntity;
BlockEntity = NULL;
}
// If the new block is a block entity, create the entity object:

View File

@ -59,6 +59,7 @@ cCraftingGrid::cCraftingGrid(const cCraftingGrid & a_Original) :
cCraftingGrid::~cCraftingGrid()
{
delete[] m_Items;
m_Items = NULL;
}

View File

@ -146,6 +146,7 @@ cPlayer::~cPlayer(void)
m_ClientHandle = NULL;
delete m_InventoryWindow;
m_InventoryWindow = NULL;
LOGD("Player %p deleted", this);
}

View File

@ -42,6 +42,7 @@ cFurnaceRecipe::~cFurnaceRecipe()
{
ClearRecipes();
delete m_pState;
m_pState = NULL;
}
@ -187,7 +188,9 @@ void cFurnaceRecipe::ClearRecipes(void)
{
Recipe R = *itr;
delete R.In;
R.In = NULL;
delete R.Out;
R.Out = NULL;
}
m_pState->Recipes.clear();
@ -195,6 +198,7 @@ void cFurnaceRecipe::ClearRecipes(void)
{
Fuel F = *itr;
delete F.In;
F.In = NULL;
}
m_pState->Fuel.clear();
}

View File

@ -135,7 +135,9 @@ cBioGenCache::cBioGenCache(cBiomeGen * a_BioGenToCache, int a_CacheSize) :
cBioGenCache::~cBioGenCache()
{
delete[] m_CacheData;
m_CacheData = NULL;
delete[] m_CacheOrder;
m_CacheOrder = NULL;
}

View File

@ -672,7 +672,9 @@ cCompoGenCache::cCompoGenCache(cTerrainCompositionGen & a_Underlying, int a_Cach
cCompoGenCache::~cCompoGenCache()
{
delete[] m_CacheData;
m_CacheData = NULL;
delete[] m_CacheOrder;
m_CacheOrder = NULL;
}

View File

@ -142,7 +142,9 @@ cHeiGenCache::cHeiGenCache(cTerrainHeightGen & a_HeiGenToCache, int a_CacheSize)
cHeiGenCache::~cHeiGenCache()
{
delete[] m_CacheData;
m_CacheData = NULL;
delete[] m_CacheOrder;
m_CacheOrder = NULL;
}

View File

@ -30,10 +30,12 @@ cGroupManager::~cGroupManager()
for( GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr )
{
delete itr->second;
itr->second = NULL;
}
m_pState->Groups.clear();
delete m_pState;
m_pState = NULL;
}

View File

@ -28,6 +28,7 @@ cHTTPConnection::~cHTTPConnection()
{
// LOGD("HTTP: Connection deleting: %p", this);
delete m_CurrentRequest;
m_CurrentRequest = NULL;
}

View File

@ -28,6 +28,7 @@ cItemGrid::cItemGrid(int a_Width, int a_Height) :
cItemGrid::~cItemGrid()
{
delete[] m_Slots;
m_Slots = NULL;
}

View File

@ -69,6 +69,7 @@ public:
if (!Arrow->Initialize(*a_Player->GetWorld()))
{
delete Arrow;
Arrow = NULL;
return;
}
a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow);

View File

@ -260,6 +260,7 @@ void cItemHandler::Deinit()
for(int i = 0; i < 2267; i++)
{
delete m_ItemHandler[i];
m_ItemHandler[i] = NULL;
}
memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); // Don't leave any dangling pointers around, just in case
m_HandlerInitialized = false;

View File

@ -37,6 +37,7 @@ public:
if (!ItemFrame->Initialize(*a_World))
{
delete ItemFrame;
ItemFrame = NULL;
return false;
}

View File

@ -57,6 +57,7 @@ cMCLogger::~cMCLogger()
{
m_Log->Log("--- Stopped Log ---\n");
delete m_Log;
m_Log = NULL;
if (this == s_MCLogger)
{
s_MCLogger = NULL;

View File

@ -47,6 +47,7 @@ void cBlaze::Attack(float a_Dt)
if (!FireCharge->Initialize(*m_World))
{
delete FireCharge;
FireCharge = NULL;
return;
}
m_World->BroadcastSpawnEntity(*FireCharge);

View File

@ -49,6 +49,7 @@ void cGhast::Attack(float a_Dt)
if (!GhastBall->Initialize(*m_World))
{
delete GhastBall;
GhastBall = NULL;
return;
}
m_World->BroadcastSpawnEntity(*GhastBall);

View File

@ -84,6 +84,7 @@ void cSkeleton::Attack(float a_Dt)
if (!Arrow->Initialize(*m_World))
{
delete Arrow;
Arrow = NULL;
return;
}
m_World->BroadcastSpawnEntity(*Arrow);

View File

@ -47,6 +47,7 @@ cMonsterConfig::cMonsterConfig(void)
cMonsterConfig::~cMonsterConfig()
{
delete m_pState;
m_pState = NULL;
}

View File

@ -877,6 +877,7 @@ void cPerlinNoise::Generate2D(
if (ShouldFreeWorkspace)
{
delete[] a_Workspace;
a_Workspace = NULL;
}
}
@ -943,6 +944,7 @@ void cPerlinNoise::Generate3D(
if (ShouldFreeWorkspace)
{
delete[] a_Workspace;
a_Workspace = NULL;
}
}
@ -1045,6 +1047,7 @@ void cRidgedMultiNoise::Generate2D(
if (ShouldFreeWorkspace)
{
delete[] a_Workspace;
a_Workspace = NULL;
}
}
@ -1111,6 +1114,7 @@ void cRidgedMultiNoise::Generate3D(
if (ShouldFreeWorkspace)
{
delete[] a_Workspace;
a_Workspace = NULL;
}
}

View File

@ -71,6 +71,7 @@ cEvent::~cEvent()
{
sem_destroy(m_Event);
delete m_Event;
m_Event = NULL;
}
#endif
}

View File

@ -61,6 +61,7 @@ bool cSocketThreads::AddClient(const cSocket & a_Socket, cCallback * a_Client)
// There was an error launching the thread (but it was already logged along with the reason)
LOGERROR("A new cSocketThread failed to start");
delete Thread;
Thread = NULL;
return false;
}
Thread->AddClient(a_Socket, a_Client);

View File

@ -66,11 +66,13 @@ cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_Thre
cThread::~cThread()
{
delete m_Event;
m_Event = NULL;
if( m_StopEvent )
{
m_StopEvent->Wait();
delete m_StopEvent;
m_StopEvent = NULL;
}
}

View File

@ -37,6 +37,7 @@ cProtocolRecognizer::cProtocolRecognizer(cClientHandle * a_Client) :
cProtocolRecognizer::~cProtocolRecognizer()
{
delete m_Protocol;
m_Protocol = NULL;
}

View File

@ -326,6 +326,7 @@ void cServer::OnConnectionAccepted(cSocket & a_Socket)
LOGERROR("Client \"%s\" cannot be handled, server probably unstable", ClientIP.c_str());
a_Socket.CloseSocket();
delete NewHandle;
NewHandle = NULL;
return;
}

View File

@ -169,7 +169,8 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
X = Pos->x;
Z = Pos->z;
}
}else if(BlockID == E_BLOCK_AIR)
}
else if(BlockID == E_BLOCK_AIR)
{
LowestPoint = 9; //This always dominates
X = Pos->x;
@ -177,6 +178,7 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
}
delete Pos;
Pos = NULL;
}
if (LowestPoint == m_World.GetBlockMeta(a_X, a_Y, a_Z))

View File

@ -524,6 +524,7 @@ void cWebAdmin::OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest &
// Delete any request data assigned to the request:
cRequestData * Data = (cRequestData *)(a_Request.GetUserData());
delete Data;
Data = NULL;
}

View File

@ -267,12 +267,12 @@ cWorld::cWorld(const AString & a_WorldName) :
cWorld::~cWorld()
{
delete m_SimulatorManager;
delete m_SandSimulator;
delete m_WaterSimulator;
delete m_LavaSimulator;
delete m_FireSimulator;
delete m_RedstoneSimulator;
delete m_SimulatorManager; m_SimulatorManager = NULL;
delete m_SandSimulator; m_SandSimulator = NULL;
delete m_WaterSimulator; m_WaterSimulator = NULL;
delete m_LavaSimulator; m_LavaSimulator = NULL;
delete m_FireSimulator; m_FireSimulator = NULL;
delete m_RedstoneSimulator; m_RedstoneSimulator = NULL;
UnloadUnusedChunks();
@ -2972,11 +2972,13 @@ int cWorld::SpawnMobFinalize(cMonster * a_Monster)
if (cPluginManager::Get()->CallHookSpawningMonster(*this, *a_Monster))
{
delete a_Monster;
a_Monster = NULL;
return -1;
}
if (!a_Monster->Initialize(*this))
{
delete a_Monster;
a_Monster = NULL;
return -1;
}
BroadcastSpawnEntity(*a_Monster);
@ -2999,6 +3001,7 @@ int cWorld::CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProje
if (!Projectile->Initialize(*this))
{
delete Projectile;
Projectile = NULL;
return -1;
}
return Projectile->GetUniqueID();

View File

@ -830,6 +830,7 @@ private:
virtual ~cScheduledTask()
{
delete m_Task;
m_Task = NULL;
}
};

View File

@ -473,6 +473,7 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_
{
LOGERROR("ERROR READING %s FROM FILE %s (line %d); file offset %d", "Header", m_FileName.c_str(), __LINE__, f.Tell());
delete Header;
Header = NULL;
return;
}
m_ChunkHeaders.push_back(Header);