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

Unified Diff: ui/surface/transport_dib.cc

Issue 12537014: Make SharedMemory track the size that was actually mapped (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 | « ui/surface/transport_dib.h ('k') | ui/surface/transport_dib_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/surface/transport_dib.cc
===================================================================
--- ui/surface/transport_dib.cc (revision 0)
+++ ui/surface/transport_dib.cc (revision 0)
@@ -0,0 +1,21 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/surface/transport_dib.h"
+
+#include "skia/ext/platform_canvas.h"
+
+// static
+bool TransportDIB::VerifyCanvasSize(int w, int h) {
+ static const size_t kMaxSize = static_cast<size_t>(INT_MAX);
+ const size_t one_stride = skia::PlatformCanvasStrideForWidth(1);
+ const size_t stride = skia::PlatformCanvasStrideForWidth(w);
+ if (w <= 0 || h <= 0 || static_cast<size_t>(w) > (kMaxSize / one_stride) ||
+ static_cast<size_t>(h) > (kMaxSize / stride)) {
+ return false;
+ }
+
+ return (stride * h) <= size_;
+}
+
Property changes on: ui\surface\transport_dib.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « ui/surface/transport_dib.h ('k') | ui/surface/transport_dib_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698