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

Side by Side Diff: tests/BitmapCopyTest.cpp

Issue 26890002: Fix uninitialized memory read in BitmapCopy test with A1 config (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Switched to use getSafeSize Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "Test.h" 8 #include "Test.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkRect.h" 10 #include "SkRect.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 if (srcOpaque.isOpaque() != dst.isOpaque()) { 50 if (srcOpaque.isOpaque() != dst.isOpaque()) {
51 report_opaqueness(reporter, srcOpaque, dst); 51 report_opaqueness(reporter, srcOpaque, dst);
52 } 52 }
53 } 53 }
54 54
55 static void init_src(const SkBitmap& bitmap) { 55 static void init_src(const SkBitmap& bitmap) {
56 SkAutoLockPixels lock(bitmap); 56 SkAutoLockPixels lock(bitmap);
57 if (bitmap.getPixels()) { 57 if (bitmap.getPixels()) {
58 if (bitmap.getColorTable()) { 58 if (bitmap.getColorTable()) {
59 sk_bzero(bitmap.getPixels(), bitmap.getSize()); 59 sk_bzero(bitmap.getPixels(), bitmap.getSize());
60 } else if (SkBitmap::kA1_Config == bitmap.config()) {
61 // The A1 config can have uninitialized bits at the
62 // end of each row if eraseColor is used
63 memset(bitmap.getPixels(), 0xff, bitmap.getSafeSize());
60 } else { 64 } else {
61 bitmap.eraseColor(SK_ColorWHITE); 65 bitmap.eraseColor(SK_ColorWHITE);
62 } 66 }
63 } 67 }
64 } 68 }
65 69
66 static SkColorTable* init_ctable(SkAlphaType alphaType) { 70 static SkColorTable* init_ctable(SkAlphaType alphaType) {
67 static const SkColor colors[] = { 71 static const SkColor colors[] = {
68 SK_ColorBLACK, SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE 72 SK_ColorBLACK, SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE
69 }; 73 };
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 false); 595 false);
592 596
593 #endif 597 #endif
594 } 598 }
595 } // for (size_t copyCase ... 599 } // for (size_t copyCase ...
596 } 600 }
597 } 601 }
598 602
599 #include "TestClassDef.h" 603 #include "TestClassDef.h"
600 DEFINE_TESTCLASS("BitmapCopy", TestBitmapCopyClass, TestBitmapCopy) 604 DEFINE_TESTCLASS("BitmapCopy", TestBitmapCopyClass, TestBitmapCopy)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698