Commit 321f840f authored by Matt Reynolds's avatar Matt Reynolds Committed by Commit Bot

Reland "[gamepad] Add null PadState check in..."

"...NintendoDataFetcher"

This is a reland of 6edcc8d4

Original change's description:
> In NintendoDataFetcher::GetGamepadData we call GetPadState to
> get a pointer to an unused PadState slot. This pointer may be
> null if there are no more unused slots (Chrome supports at most
> four connected gamepads).
>
> This CL adds a null check so we don't try to dereference the
> null PadState and crash.
>
> BUG=996052
>
> Change-Id: I48cb1611b1c557e5eaa1a5791bf68d5acf8841ad
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762603
> Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
> Reviewed-by: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#689709}

BUG=996052

Change-Id: I499f223063c6889ec996c10890c5bd47e3260540
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769413Reviewed-by: default avatarOvidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691817}
parent e415bcce
......@@ -181,6 +181,9 @@ void NintendoDataFetcher::GetGamepadData(bool) {
auto& device = entry.second;
if (device->IsOpen() && device->IsUsable()) {
PadState* state = GetPadState(device->GetSourceId());
if (!state)
continue;
if (!state->is_initialized) {
state->mapper = device->GetMappingFunction();
device->InitializeGamepadState(state->mapper != nullptr, state->data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment