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

Side by Side Diff: tests/BitmapTest.cpp

Issue 871993003: check for too-large rowBytes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use cast to keep minRB signed (matching the rest of the code) Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/core/SkMallocPixelRef.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkMallocPixelRef.h"
10 #include "Test.h"
9 11
10 #include "Test.h" 12 // https://code.google.com/p/chromium/issues/detail?id=446164
13 static void test_bigalloc(skiatest::Reporter* reporter) {
14 const int width = 0x40000001;
15 const int height = 0x00000096;
16 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
17
18 SkBitmap bm;
19 REPORTER_ASSERT(reporter, !bm.tryAllocPixels(info));
20
21 SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, info.minRowBytes(), NUL L);
22 REPORTER_ASSERT(reporter, !pr);
23 }
11 24
12 static void test_allocpixels(skiatest::Reporter* reporter) { 25 static void test_allocpixels(skiatest::Reporter* reporter) {
13 const int width = 10; 26 const int width = 10;
14 const int height = 10; 27 const int height = 10;
15 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 28 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
16 const size_t explicitRowBytes = info.minRowBytes() + 24; 29 const size_t explicitRowBytes = info.minRowBytes() + 24;
17 30
18 SkBitmap bm; 31 SkBitmap bm;
19 bm.setInfo(info); 32 bm.setInfo(info);
20 REPORTER_ASSERT(reporter, info.minRowBytes() == bm.rowBytes()); 33 REPORTER_ASSERT(reporter, info.minRowBytes() == bm.rowBytes());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 REPORTER_ASSERT(reporter, setConf); 87 REPORTER_ASSERT(reporter, setConf);
75 if (setConf) { 88 if (setConf) {
76 bm.allocPixels(); 89 bm.allocPixels();
77 } 90 }
78 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty()); 91 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty());
79 } 92 }
80 } 93 }
81 94
82 test_bigwidth(reporter); 95 test_bigwidth(reporter);
83 test_allocpixels(reporter); 96 test_allocpixels(reporter);
97 test_bigalloc(reporter);
84 } 98 }
OLDNEW
« no previous file with comments | « src/core/SkMallocPixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698