fix: Add safety checks for input processing and callback cleanup

- Prevent controller input processing until emulation is fully running
- Add null checks and prevent double deletion of NPAD callbacks
- Set callback_key to -1 after deletion to prevent reuse

Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2025-12-03 12:12:14 +10:00
parent 79fcbf536e
commit 78cbfcf1a7
2 changed files with 11 additions and 1 deletions

View File

@@ -5573,6 +5573,11 @@ void GMainWindow::UpdateUISettings() {
}
void GMainWindow::UpdateInputDrivers() {
// Do not process ANY controller input until emulation is fully running
if (!emulation_running) {
return;
}
if (!input_subsystem) {
return;
}

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-FileCopyrightText: 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
@@ -46,10 +47,14 @@ NPad::NPad(Core::HID::HIDCore& hid_core_, KernelHelpers::ServiceContext& service
}
NPad::~NPad() {
// Iterate over ALL aruids and ALL controllers to delete every callback
for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) {
for (std::size_t i = 0; i < controller_data[aruid_index].size(); ++i) {
auto& controller = controller_data[aruid_index][i];
controller.device->DeleteCallback(controller.callback_key);
if (controller.device && controller.callback_key != -1) {
controller.device->DeleteCallback(controller.callback_key);
controller.callback_key = -1; // Prevent double deletion
}
}
}
}