|
OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/surface/transport_dib.h" | |
6 | |
7 #include "skia/ext/platform_canvas.h" | |
8 | |
9 // static | |
10 bool TransportDIB::VerifyCanvasSize(int w, int h) { | |
11 static const size_t kMaxSize = static_cast<size_t>(INT_MAX); | |
12 const size_t one_stride = skia::PlatformCanvasStrideForWidth(1); | |
13 const size_t stride = skia::PlatformCanvasStrideForWidth(w); | |
14 if (w <= 0 || h <= 0 || static_cast<size_t>(w) > (kMaxSize / one_stride) || | |
apatrick_chromium
2013/03/18 17:32:10
nit: braces around "return false".
jschuh
2013/03/21 01:08:03
Done.
| |
15 static_cast<size_t>(h) > (kMaxSize / stride)) | |
16 return false; | |
17 | |
18 return (stride * h) <= size_; | |
apatrick_chromium
2013/03/18 17:32:10
Are we worried about (stride * h) overflowing or b
jschuh
2013/03/21 01:08:03
The checks above verify it's positive and won't ov
| |
19 } | |
20 | |
OLD | NEW |