Chromium Code Reviews| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 size_t inc = SkAlign4(size); | 85 size_t inc = SkAlign4(size); |
| 86 const void* addr = fReader.peek(); | 86 const void* addr = fReader.peek(); |
| 87 fError |= !ptr_align_4(addr) || !fReader.isAvailable(inc); | 87 fError |= !ptr_align_4(addr) || !fReader.isAvailable(inc); |
| 88 if (!fError) { | 88 if (!fError) { |
| 89 fReader.skip(size); | 89 fReader.skip(size); |
| 90 } | 90 } |
| 91 return addr; | 91 return addr; |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool SkValidatingReadBuffer::readBool() { | 94 bool SkValidatingReadBuffer::readBool() { |
| 95 const void* addr = fReader.peek(); | |
| 96 const uint32_t* boolPtr = static_cast<const uint32_t*>(addr); | |
| 97 // Boolean value should be either 0 or 1 | |
| 98 fError |= !boolPtr || (*boolPtr) & 0xFFFFFFFE; | |
|
reed1
2013/09/13 15:42:56
Why are we dealing with ptrs and casts here? Why n
sugoi1
2013/09/13 16:53:44
You're right, I was originally thinking of a more
| |
| 95 return this->readInt() != 0; | 99 return this->readInt() != 0; |
| 96 } | 100 } |
| 97 | 101 |
| 98 SkColor SkValidatingReadBuffer::readColor() { | 102 SkColor SkValidatingReadBuffer::readColor() { |
| 99 return this->readInt(); | 103 return this->readInt(); |
| 100 } | 104 } |
| 101 | 105 |
| 102 SkFixed SkValidatingReadBuffer::readFixed() { | 106 SkFixed SkValidatingReadBuffer::readFixed() { |
| 103 return this->readInt(); | 107 return this->readInt(); |
| 104 } | 108 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 fError = true; | 285 fError = true; |
| 282 delete obj; | 286 delete obj; |
| 283 obj = NULL; | 287 obj = NULL; |
| 284 } | 288 } |
| 285 } else { | 289 } else { |
| 286 // we must skip the remaining data | 290 // we must skip the remaining data |
| 287 this->skip(sizeRecorded); | 291 this->skip(sizeRecorded); |
| 288 } | 292 } |
| 289 return obj; | 293 return obj; |
| 290 } | 294 } |
| OLD | NEW |