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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 | 84 |
| 85 uint32_t SkValidatingReadBuffer::readUInt() { | 85 uint32_t SkValidatingReadBuffer::readUInt() { |
| 86 return this->readInt(); | 86 return this->readInt(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 int32_t SkValidatingReadBuffer::read32() { | 89 int32_t SkValidatingReadBuffer::read32() { |
| 90 return this->readInt(); | 90 return this->readInt(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void SkValidatingReadBuffer::readString(SkString* string) { | 93 void SkValidatingReadBuffer::readString(SkString* string) { |
| 94 const size_t len = this->readInt(); | 94 const int32_t len32 = this->readInt(); |
|
Stephen White
2014/04/28 19:48:33
I think we should be reading a uint32_t here (sinc
sugoi1
2014/04/28 20:15:20
Done.
| |
| 95 // Make sure len32 is a positive number before it gets converted to an unsig ned integer format | |
| 96 if (!this->validate(len32 >= 0)) { | |
| 97 return; | |
| 98 } | |
| 99 | |
| 100 const size_t len(len32); | |
| 95 const void* ptr = fReader.peek(); | 101 const void* ptr = fReader.peek(); |
| 96 const char* cptr = (const char*)ptr; | 102 const char* cptr = (const char*)ptr; |
| 97 | 103 |
| 98 // skip over the string + '\0' and then pad to a multiple of 4 | 104 // skip over the string + '\0' and then pad to a multiple of 4 |
| 99 const size_t alignedSize = SkAlign4(len + 1); | 105 const size_t alignedSize = SkAlign4(len + 1); |
| 100 this->skip(alignedSize); | 106 this->skip(alignedSize); |
| 101 if (!fError) { | 107 if (!fError) { |
| 102 this->validate(cptr[len] == '\0'); | 108 this->validate(cptr[len] == '\0'); |
| 103 } | 109 } |
| 104 if (!fError) { | 110 if (!fError) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 delete obj; | 272 delete obj; |
| 267 obj = NULL; | 273 obj = NULL; |
| 268 } | 274 } |
| 269 } else { | 275 } else { |
| 270 // we must skip the remaining data | 276 // we must skip the remaining data |
| 271 this->skip(sizeRecorded); | 277 this->skip(sizeRecorded); |
| 272 SkASSERT(false); | 278 SkASSERT(false); |
| 273 } | 279 } |
| 274 return obj; | 280 return obj; |
| 275 } | 281 } |
| OLD | NEW |