OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
10 #include "SkValidatingReadBuffer.h" | 10 #include "SkValidatingReadBuffer.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 bitmap->unflatten(*this); | 222 bitmap->unflatten(*this); |
223 this->validate((bitmap->width() == width) && (bitmap->height() == height)); | 223 this->validate((bitmap->width() == width) && (bitmap->height() == height)); |
224 } | 224 } |
225 | 225 |
226 SkTypeface* SkValidatingReadBuffer::readTypeface() { | 226 SkTypeface* SkValidatingReadBuffer::readTypeface() { |
227 // TODO: Implement this (securely) when needed | 227 // TODO: Implement this (securely) when needed |
228 return NULL; | 228 return NULL; |
229 } | 229 } |
230 | 230 |
| 231 bool SkValidatingReadBuffer::validateAvailable(size_t size) { |
| 232 return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast
<uint32_t>(size))); |
| 233 } |
| 234 |
231 SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type)
{ | 235 SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type)
{ |
232 SkString name; | 236 SkString name; |
233 this->readString(&name); | 237 this->readString(&name); |
234 if (fError) { | 238 if (fError) { |
235 return NULL; | 239 return NULL; |
236 } | 240 } |
237 | 241 |
238 // Is this the type we wanted ? | 242 // Is this the type we wanted ? |
239 const char* cname = name.c_str(); | 243 const char* cname = name.c_str(); |
240 SkFlattenable::Type baseType; | 244 SkFlattenable::Type baseType; |
(...skipping 21 matching lines...) Expand all Loading... |
262 delete obj; | 266 delete obj; |
263 obj = NULL; | 267 obj = NULL; |
264 } | 268 } |
265 } else { | 269 } else { |
266 // we must skip the remaining data | 270 // we must skip the remaining data |
267 this->skip(sizeRecorded); | 271 this->skip(sizeRecorded); |
268 SkASSERT(false); | 272 SkASSERT(false); |
269 } | 273 } |
270 return obj; | 274 return obj; |
271 } | 275 } |
OLD | NEW |