From 8efc29972dd883d230a5729701e0f762eaaacc61 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 27 Jan 2022 21:06:37 +0100 Subject: [PATCH] input: add missing nullptr checks for pad --- rpcs3/Emu/Io/PadHandler.cpp | 5 +++++ rpcs3/Input/keyboard_pad_handler.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Io/PadHandler.cpp b/rpcs3/Emu/Io/PadHandler.cpp index 95e00a1d0a..2d6e7cb212 100644 --- a/rpcs3/Emu/Io/PadHandler.cpp +++ b/rpcs3/Emu/Io/PadHandler.cpp @@ -431,6 +431,11 @@ void PadHandlerBase::TranslateButtonPress(const std::shared_ptr& devi bool PadHandlerBase::bindPadToDevice(std::shared_ptr pad, const std::string& device, u8 player_id) { + if (!pad) + { + return false; + } + std::shared_ptr pad_device = get_device(device); if (!pad_device) { diff --git a/rpcs3/Input/keyboard_pad_handler.cpp b/rpcs3/Input/keyboard_pad_handler.cpp index a8f323b3de..72982c23ff 100644 --- a/rpcs3/Input/keyboard_pad_handler.cpp +++ b/rpcs3/Input/keyboard_pad_handler.cpp @@ -750,7 +750,7 @@ std::string keyboard_pad_handler::native_scan_code_to_string(int native_scan_cod bool keyboard_pad_handler::bindPadToDevice(std::shared_ptr pad, const std::string& device, u8 player_id) { - if (device != pad::keyboard_device_name) + if (!pad || device != pad::keyboard_device_name) return false; m_pad_configs[player_id].from_string(g_cfg_input.player[player_id]->config.to_string());