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

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: Fixed pending comments 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
« no previous file with comments | « 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..2bf0b572acdbc50850c7786352da003c8c67fd47 100644
--- a/ppapi/shared_impl/ppb_gamepad_shared.cc
+++ b/ppapi/shared_impl/ppb_gamepad_shared.cc
@@ -4,14 +4,20 @@
#include "ppapi/shared_impl/ppb_gamepad_shared.h"
+#include <algorithm>
+
#include "base/basictypes.h"
namespace ppapi {
+const size_t WebKitGamepads::kItemsLengthCap;
+
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) {
+ size_t length = std::min(WebKitGamepads::kItemsLengthCap,
+ static_cast<const size_t>(webkit_data.length));
+ output_data->length = static_cast<unsigned>(length);
+ for (unsigned i = 0; i < 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;
« no previous file with comments | « ppapi/examples/gamepad/gamepad.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698