mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 00:46:46 +00:00
[Bug Fix] Fix miscellaneous memory leaks related to EQApplicationPacket and it's pBuffer (#2262)
* Delete EQApplicationPacket after use * Correct issue where Creating EQApplicationPackets in zone/mob.cpp may not free pBuffer[] * Handle freeing pBuffer[] if exists in zone/mob.cpp Create*Packet functions * Handle freeing pBuffer[] in zone/object.cpp Create*Packet methods * Delete leaked outapp variables in zone/trading.cpp * Make CreateHorseSpawnPacket() safer by freeing pBuffer[] before replacing with new[] * Prevent initial new ServerPacket from being leaked in command_reload * Free pack after sending in command_setlsinfo * Delete new NPC in command_viewnpctype after printing stats * Fix compile error * Delete EQApplicationPacket after sending in command_kick * Remove unneeded safe_delete(outapp) after FastQueuePacket and fix minor whitespace issue * Delete packet after sending in WorldServer::SendReloadTasks * Cleanup logic and free leaked NPCType in Client::Doppelganger * Free RespawnOption in Client::HandleRespawnFromHover in 'unexpected rez from hover request' branch * Free EQApplicationPacket after sending in Bot::ProcessBotInspectionRequest * Free Bot when returning from failed Bot::Save() in helper_bot_create() * Initialize variable to nullptr to prevent garbage initial value * Undo change in other PR
This commit is contained in:
@@ -17,6 +17,7 @@ void command_kick(Client *c, const Seperator *sep)
|
||||
if (client->Admin() <= c->Admin()) {
|
||||
auto outapp = new EQApplicationPacket(OP_GMKick, 0);
|
||||
client->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
client->Kick("Ordered kicked by command");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
|
||||
@@ -1122,8 +1122,8 @@ void command_object(Client *c, const Seperator *sep)
|
||||
app = new EQApplicationPacket();
|
||||
o->CreateDeSpawnPacket(app);
|
||||
entity_list.QueueClients(nullptr, app);
|
||||
|
||||
entity_list.RemoveObject(o->GetID());
|
||||
safe_delete(app);
|
||||
|
||||
// Verifying ZoneID and Version in case someone else ended up adding an object with our ID
|
||||
// from a different zone/version. Don't want to delete someone else's work.
|
||||
|
||||
@@ -61,7 +61,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
auto pack = new ServerPacket;
|
||||
ServerPacket* pack = nullptr;
|
||||
|
||||
if (is_aa) {
|
||||
c->Message(Chat::White, "Attempting to reload Alternate Advancement Data globally.");
|
||||
@@ -282,7 +282,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
pack = new ServerPacket(ServerOP_ReloadZonePoints, 0);
|
||||
}
|
||||
|
||||
if (pack->opcode) {
|
||||
if (pack) {
|
||||
worldserver.SendPacket(pack);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ void command_setlsinfo(Client *c, const Seperator *sep)
|
||||
strn0cpy(s->user_email, sep->arg[1], 100);
|
||||
strn0cpy(s->userpassword, sep->arg[2], 50);
|
||||
worldserver.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
c->Message(Chat::White, "Your email and local loginserver password have been set.");
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ void command_viewnpctype(Client *c, const Seperator *sep)
|
||||
GravityBehavior::Water
|
||||
);
|
||||
npc->ShowStats(c);
|
||||
safe_delete(npc);
|
||||
}
|
||||
else {
|
||||
c->Message(
|
||||
|
||||
Reference in New Issue
Block a user