From 3951ca6f48715cd4f36a6b5769facb33bda94e66 Mon Sep 17 00:00:00 2001 From: erwan celanie Date: Sun, 10 Jan 2021 12:12:37 -0400 Subject: [PATCH] fix .give crash --- Horion/Command/Commands/GiveCommand.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Horion/Command/Commands/GiveCommand.cpp b/Horion/Command/Commands/GiveCommand.cpp index 34a7e1ad..f4f1350e 100644 --- a/Horion/Command/Commands/GiveCommand.cpp +++ b/Horion/Command/Commands/GiveCommand.cpp @@ -27,26 +27,23 @@ bool GiveCommand::execute(std::vector* args) { auto transactionManager = g_Data.getLocalPlayer()->getTransactionManager(); if (itemId == 0) { - void* ItemPtr = malloc(0x8); - void* idk = malloc(0x0); TextHolder tempText(args->at(1)); - C_Item*** cStack = ItemRegistry::lookUpByName(ItemPtr, idk, tempText); + std::unique_ptr ItemPtr = std::make_unique(); + std::unique_ptr buffer = std::make_unique(); + C_Item*** cStack = ItemRegistry::lookUpByName(ItemPtr.get(), buffer.get(), tempText); if (*cStack == nullptr) { clientMessageF("%sInvalid item name!", RED); return true; } yot = new C_ItemStack(***cStack, count, itemData); - free(ItemPtr); - free(idk); } else { - void* ItemPtr = malloc(0x8); - C_Item*** cStack = ItemRegistry::getItemFromId(ItemPtr, itemId); + std::unique_ptr ItemPtr = std::make_unique(); + C_Item*** cStack = ItemRegistry::getItemFromId(ItemPtr.get(), itemId); if (cStack == nullptr || *cStack == nullptr || **cStack == nullptr) { clientMessageF("%sInvalid item ID!", RED); return true; } yot = new C_ItemStack(***cStack, count, itemData); - free(ItemPtr); } if (yot != nullptr)