diff --git a/UnleashedRecomp/cpu/guest_stack_var.h b/UnleashedRecomp/cpu/guest_stack_var.h index 541e3651..e4e9406d 100644 --- a/UnleashedRecomp/cpu/guest_stack_var.h +++ b/UnleashedRecomp/cpu/guest_stack_var.h @@ -6,7 +6,7 @@ // DO NOT use this type as anything other than a local variable. // This includes returning. It'll cause memory to leak in the guest stack! -template +template class guest_stack_var { private: @@ -36,19 +36,25 @@ public: guest_stack_var(Args&&... args) { AllocGuestStackMemory(); - new (get()) T(std::forward(args)...); + + if (Init) + new (get()) T(std::forward(args)...); } guest_stack_var(const guest_stack_var& other) { AllocGuestStackMemory(); - new (get()) T(*other->get()); + + if (Init) + new (get()) T(*other->get()); } guest_stack_var(guest_stack_var&& other) { AllocGuestStackMemory(); - new (get()) T(std::move(*other->get())); + + if (Init) + new (get()) T(std::move(*other->get())); } ~guest_stack_var()