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

Side by Side Diff: src/effects/gradients/SkGradientShader.cpp

Issue 116773002: Fixed more fuzzer issues (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Changed isAvailable for validateAvailable Created 7 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkGradientShaderPriv.h" 8 #include "SkGradientShaderPriv.h"
9 #include "SkLinearGradient.h" 9 #include "SkLinearGradient.h"
10 #include "SkRadialGradient.h" 10 #include "SkRadialGradient.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 fCacheAlpha = 256; 147 fCacheAlpha = 256;
148 148
149 fMapper = buffer.readUnitMapper(); 149 fMapper = buffer.readUnitMapper();
150 150
151 fCache16 = fCache16Storage = NULL; 151 fCache16 = fCache16Storage = NULL;
152 fCache32 = NULL; 152 fCache32 = NULL;
153 fCache32PixelRef = NULL; 153 fCache32PixelRef = NULL;
154 154
155 int colorCount = fColorCount = buffer.getArrayCount(); 155 int colorCount = fColorCount = buffer.getArrayCount();
156 if (colorCount > kColorStorageCount) { 156 if (colorCount > kColorStorageCount) {
157 size_t size = sizeof(SkColor) + sizeof(SkPMColor) + sizeof(Rec); 157 size_t allocSize = (sizeof(SkColor) + sizeof(SkPMColor) + sizeof(Rec)) * colorCount;
158 fOrigColors = (SkColor*)sk_malloc_throw(size * colorCount); 158 if (buffer.validateAvailable(allocSize)) {
159 fOrigColors = reinterpret_cast<SkColor*>(sk_malloc_throw(allocSize)) ;
160 } else {
161 fOrigColors = NULL;
162 colorCount = fColorCount = 0;
163 }
159 } else { 164 } else {
160 fOrigColors = fStorage; 165 fOrigColors = fStorage;
161 } 166 }
162 buffer.readColorArray(fOrigColors, colorCount); 167 buffer.readColorArray(fOrigColors, colorCount);
163 168
164 { 169 {
165 uint32_t packed = buffer.readUInt(); 170 uint32_t packed = buffer.readUInt();
166 fGradFlags = SkToU8(unpack_flags(packed)); 171 fGradFlags = SkToU8(unpack_flags(packed));
167 fTileMode = unpack_mode(packed); 172 fTileMode = unpack_mode(packed);
168 } 173 }
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 (*stops)[i] = stop; 1138 (*stops)[i] = stop;
1134 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1139 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1135 } 1140 }
1136 } 1141 }
1137 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1142 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1138 1143
1139 return outColors; 1144 return outColors;
1140 } 1145 }
1141 1146
1142 #endif 1147 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698