From ff3eee27da26b75e60998f6d41cf59f9e2a120bd Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 31 Dec 2014 09:20:48 -0200 Subject: [PATCH] Kernel: Don't re-assign object's handle when duplicating one --- src/core/hle/kernel/kernel.cpp | 3 ++- src/core/hle/kernel/kernel.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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; }