Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2196)

Unified Diff: ppapi/shared_impl/ppb_gamepad_shared.cc

Issue 1136463002: Pass correct length value in WebGamepads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ppapi/examples/gamepad/gamepad.cc ('K') | « ppapi/examples/gamepad/gamepad.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/ppb_gamepad_shared.cc
diff --git a/ppapi/shared_impl/ppb_gamepad_shared.cc b/ppapi/shared_impl/ppb_gamepad_shared.cc
index 7aa752a8aab561a2d8eba127baed419c77e5ed5d..59b819026fa3d6ea1e9c6ff2de6c0ff8de52c9a4 100644
--- a/ppapi/shared_impl/ppb_gamepad_shared.cc
+++ b/ppapi/shared_impl/ppb_gamepad_shared.cc
@@ -10,8 +10,9 @@ namespace ppapi {
void ConvertWebKitGamepadData(const WebKitGamepads& webkit_data,
PP_GamepadsSampleData* output_data) {
- output_data->length = webkit_data.length;
- for (unsigned i = 0; i < webkit_data.length; ++i) {
+ output_data->length = (webkit_data.length < WebKitGamepads::kItemsLengthCap) ?
+ webkit_data.length : WebKitGamepads::kItemsLengthCap;
arajp 2015/05/07 12:19:54 Added this for safety.
bbudge 2015/05/07 13:58:57 std::min(webkit_data.length, WebKitGamepads::kItem
arajp 2015/05/08 06:03:20 Done.
+ for (unsigned i = 0; i < output_data->length; ++i) {
PP_GamepadSampleData& output_pad = output_data->items[i];
const WebKitGamepad& webkit_pad = webkit_data.items[i];
output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE;
« ppapi/examples/gamepad/gamepad.cc ('K') | « ppapi/examples/gamepad/gamepad.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698