diff options
| author | JosJuice <josjuice@gmail.com> | 2023-08-15 13:31:18 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2023-08-15 13:31:18 +0200 |
| commit | 1d77bddc3b4090ebc4541375bf4caef18e3b6868 (patch) | |
| tree | 83898f0bdecb50be9fa62fed7bb2bc85480a9729 /Source/Core/InputCommon/ControllerInterface/Android/Android.cpp | |
| parent | 54d3a226f342318d419c03a5b2b57bca5f42c9dd (diff) | |
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.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Android/Android.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Android/Android.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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<AndroidDevice>(env, input_device); env->DeleteLocalRef(input_device); |
