Browse Source

[hid_core] fix NPad crash on pikmin 4 due to nullref (#4249)

Signed-off-by: lizzie <lizzie@eden-emu.dev>

- [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions).
- [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md)
- [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability.

-------------------

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4249
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Reviewed-by: Maufeat <sahyno1996@gmail.com>
master
lizzie 21 hours ago
committed by crueter
parent
commit
a0f1cd1baf
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 7
      src/hid_core/resources/npad/npad.cpp

7
src/hid_core/resources/npad/npad.cpp

@ -504,9 +504,12 @@ void NPad::OnUpdate(Kernel::KernelCore& kernel, const Core::Timing::CoreTiming&
for (std::size_t i = 0; i < controller_data[aruid_index].size(); ++i) { for (std::size_t i = 0; i < controller_data[aruid_index].size(); ++i) {
auto& controller = controller_data[aruid_index][i]; auto& controller = controller_data[aruid_index][i];
controller.shared_memory =
&data->shared_memory_format->npad.npad_entry[i].internal_state;
controller.shared_memory = &data->shared_memory_format->npad.npad_entry[i].internal_state;
auto* npad = controller.shared_memory; auto* npad = controller.shared_memory;
if (!npad || !controller.device) {
LOG_WARNING(Service_HID, "No device for {}", i);
continue;
}
const auto& controller_type = controller.device->GetNpadStyleIndex(); const auto& controller_type = controller.device->GetNpadStyleIndex();

Loading…
Cancel
Save