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; }