From 8d7dcac56315f1b398245e846040b75e0b3a826c Mon Sep 17 00:00:00 2001 From: Jiga228 Date: Thu, 23 Oct 2025 23:04:33 +0700 Subject: [PATCH] Fix crash in Release configuration --- Core/Types/object_ptr.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Core/Types/object_ptr.hpp b/Core/Types/object_ptr.hpp index 3b8414b..aa1146f 100644 --- a/Core/Types/object_ptr.hpp +++ b/Core/Types/object_ptr.hpp @@ -154,9 +154,19 @@ static void add_owner(object_ptr& ptr) if (ptr_) counter::remove_object(ptr_); } - Ty* get() const noexcept { return ptr_.load(); } - Ty& operator*() const noexcept { return *ptr_; } - Ty* operator->() const noexcept { return ptr_.load(); } + Ty* get() const { return ptr_.load(); } + Ty& operator*() const + { + if (!ptr_.load()) + throw std::runtime_error("Null pointer"); + return *ptr_; + } + Ty* operator->() const + { + if (!ptr_.load()) + throw std::runtime_error("Null pointer"); + return ptr_.load(); + } operator bool() const noexcept { return ptr_.load() != nullptr; } object_ptr& operator=(const object_ptr& ptr) {