diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index d3ce20f65..dba840c08 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -39,7 +39,8 @@ ResultVal HandleTable::Create(std::shared_ptr obj) { if (next_generation >= (1 << 15)) next_generation = 1; Handle handle = generation | (slot << 15); - obj->handle = handle; + if (obj->handle == INVALID_HANDLE) + obj->handle = handle; generations[slot] = generation; objects[slot] = std::move(obj); diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 1b2479e7e..ad1991446 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -53,7 +53,7 @@ class HandleTable; class Object : NonCopyable, public std::enable_shared_from_this { friend class HandleTable; - u32 handle; + u32 handle = INVALID_HANDLE; public: virtual ~Object() {} Handle GetHandle() const { return handle; }