From 1e2457b2662cb5bb1314b98017d3f4fb5437ce64 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 6 Jan 2023 14:17:18 +0100 Subject: [PATCH] PatchedFunctionData. Actually return on error instead of allocating even more memory --- source/PatchedFunctionData.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/PatchedFunctionData.cpp b/source/PatchedFunctionData.cpp index 1e3a489..c787a66 100644 --- a/source/PatchedFunctionData.cpp +++ b/source/PatchedFunctionData.cpp @@ -29,6 +29,11 @@ std::optional> PatchedFunctionData::make_sh ptr->jumpToOriginal = (uint32_t *) MEMAllocFromExpHeapEx(ptr->heapHandle, 0x5 * sizeof(uint32_t), 4); + if (!ptr->jumpToOriginal) { + DEBUG_FUNCTION_LINE_ERR("Failed to alloc jump data"); + return {}; + } + if (ptr->replacementFunctionAddress > 0x01FFFFFC || ptr->targetProcess != FP_TARGET_PROCESS_ALL) { ptr->jumpDataSize = 15; // We could predict the actual size and save some memory, but at the moment we don't need it. ptr->jumpData = (uint32_t *) MEMAllocFromExpHeapEx(ptr->heapHandle, ptr->jumpDataSize * sizeof(uint32_t), 4); @@ -39,11 +44,6 @@ std::optional> PatchedFunctionData::make_sh } } - if (!ptr->jumpToOriginal) { - DEBUG_FUNCTION_LINE_ERR("Failed to alloc jump data"); - return {}; - } - return ptr; }