From 1d77bddc3b4090ebc4541375bf4caef18e3b6868 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 15 Aug 2023 13:31:18 +0200 Subject: [PATCH] ControllerInterface/Android: Add null check to AddDevice The Google Play Console is showing some users getting a crash here, and indeed, InputDevice.getDevice can return null. --- .../InputCommon/ControllerInterface/Android/Android.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp index 1fa4f1c42b..50858cd3de 100644 --- a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp @@ -908,6 +908,12 @@ static void AddDevice(JNIEnv* env, int device_id) jobject input_device = env->CallStaticObjectMethod(s_input_device_class, s_input_device_get_device, device_id); + if (!input_device) + { + ERROR_LOG_FMT(CONTROLLERINTERFACE, "Could not find device with ID {}", device_id); + return; + } + auto device = std::make_shared(env, input_device); env->DeleteLocalRef(input_device);