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

Side by Side Diff: src/core/SkImageInfo.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 2010 Google Inc. 2 * Copyright 2010 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 "SkImageInfo.h" 8 #include "SkImageInfo.h"
9 #include "SkFlattenableBuffers.h" 9 #include "SkFlattenableBuffers.h"
10 10
11 static bool alpha_type_is_valid(SkAlphaType alphaType) {
12 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType);
13 }
14
15 static bool color_type_is_valid(SkColorType colorType) {
16 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType);
17 }
18
11 void SkImageInfo::unflatten(SkFlattenableReadBuffer& buffer) { 19 void SkImageInfo::unflatten(SkFlattenableReadBuffer& buffer) {
12 fWidth = buffer.read32(); 20 fWidth = buffer.read32();
13 fHeight = buffer.read32(); 21 fHeight = buffer.read32();
14 22
15 uint32_t packed = buffer.read32(); 23 uint32_t packed = buffer.read32();
16 SkASSERT(0 == (packed >> 16)); 24 SkASSERT(0 == (packed >> 16));
17 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); 25 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF);
18 fColorType = (SkColorType)((packed >> 0) & 0xFF); 26 fColorType = (SkColorType)((packed >> 0) & 0xFF);
27 buffer.validate(alpha_type_is_valid(fAlphaType) &&
28 color_type_is_valid(fColorType));
19 } 29 }
20 30
21 void SkImageInfo::flatten(SkFlattenableWriteBuffer& buffer) const { 31 void SkImageInfo::flatten(SkFlattenableWriteBuffer& buffer) const {
22 buffer.write32(fWidth); 32 buffer.write32(fWidth);
23 buffer.write32(fHeight); 33 buffer.write32(fHeight);
24 34
25 SkASSERT(0 == (fAlphaType & ~0xFF)); 35 SkASSERT(0 == (fAlphaType & ~0xFF));
26 SkASSERT(0 == (fColorType & ~0xFF)); 36 SkASSERT(0 == (fColorType & ~0xFF));
27 uint32_t packed = (fAlphaType << 8) | fColorType; 37 uint32_t packed = (fAlphaType << 8) | fColorType;
28 buffer.write32(packed); 38 buffer.write32(packed);
29 } 39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698