[Memory Leak] Fix leaks in Client::Handle_OP_AugmentItem (#4612)

* [Memory Leak] Fix leaks in Client::Handle_OP_AugmentItem

* Update client_packet.cpp
This commit is contained in:
Chris Miles 2025-01-24 02:58:58 -06:00 committed by GitHub
parent b2f71f16fc
commit 986eda44aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3252,11 +3252,11 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
if (!new_aug) { // Shouldn't get the OP code without the augment on the user's cursor, but maybe it's h4x. if (!new_aug) { // Shouldn't get the OP code without the augment on the user's cursor, but maybe it's h4x.
LogError("AugmentItem OpCode with 'Insert' or 'Swap' action received, but no augment on client's cursor"); LogError("AugmentItem OpCode with 'Insert' or 'Swap' action received, but no augment on client's cursor");
Message(Chat::Red, "Error: No augment found on cursor for inserting."); Message(Chat::Red, "Error: No augment found on cursor for inserting.");
return; break;
} else { } else {
if (!RuleB(Inventory, AllowMultipleOfSameAugment) && tobe_auged->ContainsAugmentByID(new_aug->GetID())) { if (!RuleB(Inventory, AllowMultipleOfSameAugment) && tobe_auged->ContainsAugmentByID(new_aug->GetID())) {
Message(Chat::Red, "Error: Cannot put multiple of the same augment in an item."); Message(Chat::Red, "Error: Cannot put multiple of the same augment in an item.");
return; break;
} }
if ( if (
@ -3340,7 +3340,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
in_augment->augment_index in_augment->augment_index
).c_str() ).c_str()
); );
return; break;
} }
item_one_to_push = tobe_auged->Clone(); item_one_to_push = tobe_auged->Clone();
@ -3412,7 +3412,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
} }
} else { } else {
Message(Chat::Red, "Error: Could not find augmentation to remove at index %i. Aborting.", in_augment->augment_index); Message(Chat::Red, "Error: Could not find augmentation to remove at index %i. Aborting.", in_augment->augment_index);
return; break;
} }
old_aug = tobe_auged->RemoveAugment(in_augment->augment_index); old_aug = tobe_auged->RemoveAugment(in_augment->augment_index);
@ -3445,7 +3445,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
if (!PutItemInInventory(EQ::invslot::slotCursor, *item_two_to_push, true)) { if (!PutItemInInventory(EQ::invslot::slotCursor, *item_two_to_push, true)) {
LogError("Problem returning augment to player's cursor after safe removal"); LogError("Problem returning augment to player's cursor after safe removal");
Message(Chat::Yellow, "Error: Failed to return augment after removal from item!"); Message(Chat::Yellow, "Error: Failed to return augment after removal from item!");
return; break;
} }
} }
break; break;
@ -3490,7 +3490,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
in_augment->augment_index in_augment->augment_index
).c_str() ).c_str()
); );
return; break;
} }
tobe_auged->DeleteAugment(in_augment->augment_index); tobe_auged->DeleteAugment(in_augment->augment_index);
@ -3511,6 +3511,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
if (material != EQ::textures::materialInvalid) { if (material != EQ::textures::materialInvalid) {
SendWearChange(material); SendWearChange(material);
} }
break; break;
default: // Unknown default: // Unknown
LogInventory( LogInventory(
@ -3524,9 +3525,12 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
); );
break; break;
} }
safe_delete(item_one_to_push);
safe_delete(item_two_to_push);
} else { } else {
Object::HandleAugmentation(this, in_augment, m_tradeskill_object); // Delegate to tradeskill object to perform combine Object::HandleAugmentation(this, in_augment, m_tradeskill_object); // Delegate to tradeskill object to perform combine
} }
return; return;
} }