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

Side by Side Diff: tests/SwizzlerTest.cpp

Issue 1072183002: Fix ASAN error (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | « 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkSwizzler.h" 8 #include "SkSwizzler.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
(...skipping 10 matching lines...) Expand all
21 SkPMColor* colorTable) { 21 SkPMColor* colorTable) {
22 22
23 // Calculate the total size of the image in bytes. Use the smallest possibl e size. 23 // Calculate the total size of the image in bytes. Use the smallest possibl e size.
24 // The offset value tells us to adjust the pointer from the memory we alloca te in order 24 // The offset value tells us to adjust the pointer from the memory we alloca te in order
25 // to test on different memory alignments. If offset is nonzero, we need to increase the 25 // to test on different memory alignments. If offset is nonzero, we need to increase the
26 // size of the memory we allocate in order to make sure that we have enough. We are 26 // size of the memory we allocate in order to make sure that we have enough. We are
27 // still allocating the smallest possible size. 27 // still allocating the smallest possible size.
28 const size_t totalBytes = imageInfo.getSafeSize(rowBytes) + offset; 28 const size_t totalBytes = imageInfo.getSafeSize(rowBytes) + offset;
29 29
30 // Create fake image data where every byte has a value of 0 30 // Create fake image data where every byte has a value of 0
31 SkAutoTDelete<uint8_t> storage((uint8_t*) sk_malloc_throw(totalBytes)); 31 SkAutoTDeleteArray<uint8_t> storage(SkNEW_ARRAY(uint8_t, totalBytes));
32 memset(storage.get(), 0, totalBytes); 32 memset(storage.get(), 0, totalBytes);
33 // Adjust the pointer in order to test on different memory alignments 33 // Adjust the pointer in order to test on different memory alignments
34 uint8_t* imageData = storage.get() + offset; 34 uint8_t* imageData = storage.get() + offset;
35 35
36 // Fill image with the fill value starting at the indicated row 36 // Fill image with the fill value starting at the indicated row
37 SkSwizzler::Fill(imageData, imageInfo, rowBytes, startRow, colorOrIndex, col orTable); 37 SkSwizzler::Fill(imageData, imageInfo, rowBytes, startRow, colorOrIndex, col orTable);
38 38
39 // Ensure that the pixels are filled properly 39 // Ensure that the pixels are filled properly
40 // The bots should catch any memory corruption 40 // The bots should catch any memory corruption
41 uint8_t* indexPtr = imageData + startRow * rowBytes; 41 uint8_t* indexPtr = imageData + startRow * rowBytes;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 // Fill with an index 104 // Fill with an index
105 check_fill(r, indexInfo, startRow, indexRowBytes, offset , kFillIndex, 105 check_fill(r, indexInfo, startRow, indexRowBytes, offset , kFillIndex,
106 NULL); 106 NULL);
107 } 107 }
108 } 108 }
109 } 109 }
110 } 110 }
111 } 111 }
112 } 112 }
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