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

Side by Side Diff: src/core/SkPictureData.h

Issue 1893423002: Fix ImageFilter fuzzer issue (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Switch SkReader32 to SkReadBuffer Created 4 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 | src/core/SkPicturePlayback.h » ('j') | src/core/SkPicturePlayback.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 #ifndef SkPictureData_DEFINED 8 #ifndef SkPictureData_DEFINED
9 #define SkPictureData_DEFINED 9 #define SkPictureData_DEFINED
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const sk_sp<SkData>& opData() const { return fOpData; } 80 const sk_sp<SkData>& opData() const { return fOpData; }
81 81
82 protected: 82 protected:
83 explicit SkPictureData(const SkPictInfo& info); 83 explicit SkPictureData(const SkPictInfo& info);
84 84
85 // Does not affect ownership of SkStream. 85 // Does not affect ownership of SkStream.
86 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc, SkTypefacePlayba ck*); 86 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc, SkTypefacePlayba ck*);
87 bool parseBuffer(SkReadBuffer& buffer); 87 bool parseBuffer(SkReadBuffer& buffer);
88 88
89 public: 89 public:
90 const SkBitmap& getBitmap(SkReader32* reader) const { 90 const SkBitmap& getBitmap(SkReadBuffer* reader) const {
91 const int index = reader->readInt(); 91 const int index = reader->readInt();
92 if (index < 0 || index >= fBitmaps.count()) {
reed1 2016/04/19 12:54:11 Seems fine, but a little repetitive. One condensa
robertphillips 2016/04/19 14:34:42 Done.
93 reader->makeInvalid();
94 return fEmptyBitmap;
95 }
92 return fBitmaps[index]; 96 return fBitmaps[index];
93 } 97 }
94 98
95 const SkImage* getImage(SkReader32* reader) const { 99 const SkImage* getImage(SkReadBuffer* reader) const {
96 const int index = reader->readInt(); 100 const int index = reader->readInt();
101 if (index < 0 || index >= fImageCount) {
102 reader->makeInvalid();
103 return nullptr;
104 }
97 return fImageRefs[index]; 105 return fImageRefs[index];
98 } 106 }
99 107
100 const SkPath& getPath(SkReader32* reader) const { 108 const SkPath& getPath(SkReadBuffer* reader) const {
101 int index = reader->readInt() - 1; 109 const int index = reader->readInt() - 1;
110 if (index < 0 || index >= fPaths.count()) {
111 reader->makeInvalid();
112 return fEmptyPath;
113 }
102 return fPaths[index]; 114 return fPaths[index];
103 } 115 }
104 116
105 const SkPicture* getPicture(SkReader32* reader) const { 117 const SkPicture* getPicture(SkReadBuffer* reader) const {
106 int index = reader->readInt(); 118 const int index = reader->readInt() - 1;
107 SkASSERT(index > 0 && index <= fPictureCount); 119 if (index < 0 || index >= fPictureCount) {
108 return fPictureRefs[index - 1]; 120 reader->makeInvalid();
121 return nullptr;
122 }
123 return fPictureRefs[index];
109 } 124 }
110 125
111 const SkPaint* getPaint(SkReader32* reader) const { 126 const SkPaint* getPaint(SkReadBuffer* reader) const {
112 int index = reader->readInt(); 127 const int index = reader->readInt() - 1;
113 if (index == 0) { 128 if (index < 0 || index >= fPaints.count()) {
129 reader->makeInvalid();
114 return nullptr; 130 return nullptr;
115 } 131 }
116 return &fPaints[index - 1]; 132 return &fPaints[index];
117 } 133 }
118 134
119 const SkTextBlob* getTextBlob(SkReader32* reader) const { 135 const SkTextBlob* getTextBlob(SkReadBuffer* reader) const {
120 int index = reader->readInt(); 136 const int index = reader->readInt() - 1;
121 SkASSERT(index > 0 && index <= fTextBlobCount); 137 if (index < 0 || index >= fTextBlobCount) {
122 return fTextBlobRefs[index - 1]; 138 reader->makeInvalid();
139 return nullptr;
140 }
141 return fTextBlobRefs[index];
123 } 142 }
124 143
125 #if SK_SUPPORT_GPU 144 #if SK_SUPPORT_GPU
126 /** 145 /**
127 * sampleCount is the number of samples-per-pixel or zero if non-MSAA. 146 * sampleCount is the number of samples-per-pixel or zero if non-MSAA.
128 * It is defaulted to be zero. 147 * It is defaulted to be zero.
129 */ 148 */
130 bool suitableForGpuRasterization(GrContext* context, const char **reason, 149 bool suitableForGpuRasterization(GrContext* context, const char **reason,
131 int sampleCount = 0) const; 150 int sampleCount = 0) const;
132 151
(...skipping 20 matching lines...) Expand all
153 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty 172 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty
154 // bitmap allows playback to draw nothing and move on. 173 // bitmap allows playback to draw nothing and move on.
155 SkBitmap fBadBitmap; 174 SkBitmap fBadBitmap;
156 175
157 SkTArray<SkBitmap> fBitmaps; 176 SkTArray<SkBitmap> fBitmaps;
158 SkTArray<SkPaint> fPaints; 177 SkTArray<SkPaint> fPaints;
159 SkTArray<SkPath> fPaths; 178 SkTArray<SkPath> fPaths;
160 179
161 sk_sp<SkData> fOpData; // opcodes and parameters 180 sk_sp<SkData> fOpData; // opcodes and parameters
162 181
182 const SkPath fEmptyPath;
183 const SkBitmap fEmptyBitmap;
184
163 const SkPicture** fPictureRefs; 185 const SkPicture** fPictureRefs;
164 int fPictureCount; 186 int fPictureCount;
165 const SkTextBlob** fTextBlobRefs; 187 const SkTextBlob** fTextBlobRefs;
166 int fTextBlobCount; 188 int fTextBlobCount;
167 const SkImage** fImageRefs; 189 const SkImage** fImageRefs;
168 int fImageCount; 190 int fImageCount;
169 191
170 SkPictureContentInfo fContentInfo; 192 SkPictureContentInfo fContentInfo;
171 193
172 SkTypefacePlayback fTFPlayback; 194 SkTypefacePlayback fTFPlayback;
173 SkFactoryPlayback* fFactoryPlayback; 195 SkFactoryPlayback* fFactoryPlayback;
174 196
175 const SkPictInfo fInfo; 197 const SkPictInfo fInfo;
176 198
177 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); 199 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec);
178 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); 200 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec);
179 201
180 void initForPlayback() const; 202 void initForPlayback() const;
181 }; 203 };
182 204
183 #endif 205 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPicturePlayback.h » ('j') | src/core/SkPicturePlayback.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698