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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 const size_t alignedSize = SkAlign4(len + 1); | 103 const size_t alignedSize = SkAlign4(len + 1); |
104 this->skip(alignedSize); | 104 this->skip(alignedSize); |
105 if (!fError) { | 105 if (!fError) { |
106 this->validate(cptr[len] == '\0'); | 106 this->validate(cptr[len] == '\0'); |
107 } | 107 } |
108 if (!fError) { | 108 if (!fError) { |
109 string->set(cptr, len); | 109 string->set(cptr, len); |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 void* SkValidatingReadBuffer::readEncodedString(size_t* length, SkPaint::TextEnc
oding encoding) { | |
114 const int32_t encodingType = this->readInt(); | |
115 this->validate(encodingType == encoding); | |
116 *length = this->readInt(); | |
117 const void* ptr = this->skip(SkAlign4(*length)); | |
118 void* data = nullptr; | |
119 if (!fError) { | |
120 data = sk_malloc_throw(*length); | |
121 memcpy(data, ptr, *length); | |
122 } | |
123 return data; | |
124 } | |
125 | |
126 void SkValidatingReadBuffer::readPoint(SkPoint* point) { | 113 void SkValidatingReadBuffer::readPoint(SkPoint* point) { |
127 point->fX = this->readScalar(); | 114 point->fX = this->readScalar(); |
128 point->fY = this->readScalar(); | 115 point->fY = this->readScalar(); |
129 } | 116 } |
130 | 117 |
131 void SkValidatingReadBuffer::readMatrix(SkMatrix* matrix) { | 118 void SkValidatingReadBuffer::readMatrix(SkMatrix* matrix) { |
132 size_t size = 0; | 119 size_t size = 0; |
133 if (!fError) { | 120 if (!fError) { |
134 size = matrix->readFromMemory(fReader.peek(), fReader.available()); | 121 size = matrix->readFromMemory(fReader.peek(), fReader.available()); |
135 this->validate((SkAlign4(size) == size) && (0 != size)); | 122 this->validate((SkAlign4(size) == size) && (0 != size)); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 284 |
298 void SkValidatingReadBuffer::skipFlattenable() { | 285 void SkValidatingReadBuffer::skipFlattenable() { |
299 SkString name; | 286 SkString name; |
300 this->readString(&name); | 287 this->readString(&name); |
301 if (fError) { | 288 if (fError) { |
302 return; | 289 return; |
303 } | 290 } |
304 uint32_t sizeRecorded = this->readUInt(); | 291 uint32_t sizeRecorded = this->readUInt(); |
305 this->skip(sizeRecorded); | 292 this->skip(sizeRecorded); |
306 } | 293 } |
OLD | NEW |