From f32a277643fb4c92429a09e19df8422029b8d57e Mon Sep 17 00:00:00 2001 From: Derision Date: Tue, 19 Mar 2013 19:22:16 +0000 Subject: [PATCH] Fixed memory leak in OP_VeteranRewardsAvailable --- common/patches/RoF.cpp | 3 ++- common/patches/SoD.cpp | 3 ++- common/patches/SoF.cpp | 3 ++- common/patches/Titanium.cpp | 3 ++- common/patches/Underfoot.cpp | 3 ++- zone/zonedb.cpp | 1 - 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/patches/RoF.cpp b/common/patches/RoF.cpp index 1c56e27cd..b44cb8f37 100644 --- a/common/patches/RoF.cpp +++ b/common/patches/RoF.cpp @@ -3150,6 +3150,7 @@ ENCODE(OP_VetRewardsAvaliable) unsigned char * __emu_buffer = inapp->pBuffer; uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); + *p = NULL; EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); uchar *old_data = __emu_buffer; @@ -3174,7 +3175,7 @@ ENCODE(OP_VetRewardsAvaliable) } dest->FastQueuePacket(&outapp_create); - delete[] __emu_buffer; + delete inapp; } ENCODE(OP_WhoAllResponse) diff --git a/common/patches/SoD.cpp b/common/patches/SoD.cpp index 99e6cd8c0..9e272a14c 100644 --- a/common/patches/SoD.cpp +++ b/common/patches/SoD.cpp @@ -2097,6 +2097,7 @@ ENCODE(OP_VetRewardsAvaliable) unsigned char * __emu_buffer = inapp->pBuffer; uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); + *p = NULL; EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); uchar *old_data = __emu_buffer; @@ -2121,7 +2122,7 @@ ENCODE(OP_VetRewardsAvaliable) } dest->FastQueuePacket(&outapp_create); - delete[] __emu_buffer; + delete inapp; } ENCODE(OP_WhoAllResponse) diff --git a/common/patches/SoF.cpp b/common/patches/SoF.cpp index b2794d9af..873f3f19d 100644 --- a/common/patches/SoF.cpp +++ b/common/patches/SoF.cpp @@ -1735,6 +1735,7 @@ ENCODE(OP_VetRewardsAvaliable) unsigned char * __emu_buffer = inapp->pBuffer; uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); + *p = NULL; EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); uchar *old_data = __emu_buffer; @@ -1759,7 +1760,7 @@ ENCODE(OP_VetRewardsAvaliable) } dest->FastQueuePacket(&outapp_create); - delete[] __emu_buffer; + delete inapp; } ENCODE(OP_DeleteSpawn) { diff --git a/common/patches/Titanium.cpp b/common/patches/Titanium.cpp index 469ba9b57..8f4624bed 100644 --- a/common/patches/Titanium.cpp +++ b/common/patches/Titanium.cpp @@ -898,6 +898,7 @@ ENCODE(OP_VetRewardsAvaliable) unsigned char * __emu_buffer = inapp->pBuffer; uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); + *p = NULL; EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); uchar *old_data = __emu_buffer; @@ -916,7 +917,7 @@ ENCODE(OP_VetRewardsAvaliable) } dest->FastQueuePacket(&outapp_create); - delete[] __emu_buffer; + delete inapp; } ENCODE(OP_InspectAnswer) { diff --git a/common/patches/Underfoot.cpp b/common/patches/Underfoot.cpp index 0da4f60c9..d56a21d3b 100644 --- a/common/patches/Underfoot.cpp +++ b/common/patches/Underfoot.cpp @@ -2157,6 +2157,7 @@ ENCODE(OP_VetRewardsAvaliable) unsigned char * __emu_buffer = inapp->pBuffer; uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); + *p = NULL; EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); uchar *old_data = __emu_buffer; @@ -2181,7 +2182,7 @@ ENCODE(OP_VetRewardsAvaliable) } dest->FastQueuePacket(&outapp_create); - delete[] __emu_buffer; + delete inapp; } ENCODE(OP_WhoAllResponse) diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 46604282f..6e2953534 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1885,7 +1885,6 @@ void ZoneDatabase::LoadMercBuffs(Merc *merc) { } safe_delete_array(Query); - Query = 0; if(errorMessage.empty() && BuffsLoaded) { if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM merc_buffs WHERE MercId = %u", merc->GetMercID()), TempErrorMessageBuffer)) {