Skip to content

VERY experimental Nintendo Switch 2 emulator

C++

hle: kernel: KClientPort: Add an assert for session count.

bunnei6c3c99c915d9
diff --git a/src/core/hle/kernel/k_client_port.cpp b/src/core/hle/kernel/k_client_port.cpp
index bcb884e8a9..ef168fe87a 100644
--- a/src/core/hle/kernel/k_client_port.cpp
+++ b/src/core/hle/kernel/k_client_port.cpp
@@ -28,6 +28,9 @@ void KClientPort::Initialize(KPort* parent_port_, s32 max_sessions_, std::string
void KClientPort::OnSessionFinalized() {
KScopedSchedulerLock sl{kernel};
+ // This might happen if a session was improperly used with this port.
+ ASSERT_MSG(num_sessions > 0, "num_sessions is invalid");
+
const auto prev = num_sessions--;
if (prev == max_sessions) {
this->NotifyAvailable();