Index: src/core/SkValidatingReadBuffer.cpp |
diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp |
index 323273d131a25d80a84d0aa671aea023f1c9f501..1331221588ca6bcb20c4e07e014791d0968fa254 100644 |
--- a/src/core/SkValidatingReadBuffer.cpp |
+++ b/src/core/SkValidatingReadBuffer.cpp |
@@ -149,58 +149,68 @@ void SkValidatingReadBuffer::readPath(SkPath* path) { |
} |
} |
-uint32_t SkValidatingReadBuffer::readByteArray(void* value) { |
- const uint32_t length = this->readUInt(); |
+bool SkValidatingReadBuffer::readByteArray(void* value, size_t size) { |
+ const uint32_t length = this->getArrayCount(); |
+ fError = fError || (size != length); |
+ (void)this->skip(sizeof(uint32_t)); // Skip array count |
sugoi1
2013/10/30 18:14:32
Here, the reason why I changed readUInt() for :
1
|
const void* ptr = this->skip(SkAlign4(length)); |
if (!fError) { |
memcpy(value, ptr, length); |
- return length; |
+ return true; |
} |
- return 0; |
+ return false; |
} |
-uint32_t SkValidatingReadBuffer::readColorArray(SkColor* colors) { |
- const uint32_t count = this->readUInt(); |
- const uint32_t byteLength = count * sizeof(SkColor); |
+bool SkValidatingReadBuffer::readColorArray(SkColor* colors, size_t size) { |
+ const uint32_t count = this->getArrayCount(); |
+ const size_t byteLength = count * sizeof(SkColor); |
+ fError = fError || (size != byteLength); |
+ (void)this->skip(sizeof(uint32_t)); // Skip array count |
const void* ptr = this->skip(SkAlign4(byteLength)); |
if (!fError) { |
memcpy(colors, ptr, byteLength); |
- return count; |
+ return true; |
} |
- return 0; |
+ return false; |
} |
-uint32_t SkValidatingReadBuffer::readIntArray(int32_t* values) { |
- const uint32_t count = this->readUInt(); |
- const uint32_t byteLength = count * sizeof(int32_t); |
+bool SkValidatingReadBuffer::readIntArray(int32_t* values, size_t size) { |
+ const uint32_t count = this->getArrayCount(); |
+ const size_t byteLength = count * sizeof(int32_t); |
+ fError = fError || (size != byteLength); |
+ (void)this->skip(sizeof(uint32_t)); // Skip array count |
const void* ptr = this->skip(SkAlign4(byteLength)); |
if (!fError) { |
memcpy(values, ptr, byteLength); |
- return count; |
+ return true; |
} |
- return 0; |
+ return false; |
} |
-uint32_t SkValidatingReadBuffer::readPointArray(SkPoint* points) { |
- const uint32_t count = this->readUInt(); |
- const uint32_t byteLength = count * sizeof(SkPoint); |
+bool SkValidatingReadBuffer::readPointArray(SkPoint* points, size_t size) { |
+ const uint32_t count = this->getArrayCount(); |
+ const size_t byteLength = count * sizeof(SkPoint); |
+ fError = fError || (size != byteLength); |
+ (void)this->skip(sizeof(uint32_t)); // Skip array count |
const void* ptr = this->skip(SkAlign4(byteLength)); |
if (!fError) { |
memcpy(points, ptr, byteLength); |
- return count; |
+ return true; |
} |
- return 0; |
+ return false; |
} |
-uint32_t SkValidatingReadBuffer::readScalarArray(SkScalar* values) { |
- const uint32_t count = this->readUInt(); |
- const uint32_t byteLength = count * sizeof(SkScalar); |
+bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) { |
+ const uint32_t count = this->getArrayCount(); |
+ const size_t byteLength = count * sizeof(SkScalar); |
+ fError = fError || (size != byteLength); |
+ (void)this->skip(sizeof(uint32_t)); // Skip array count |
const void* ptr = this->skip(SkAlign4(byteLength)); |
if (!fError) { |
memcpy(values, ptr, byteLength); |
- return count; |
+ return true; |
} |
- return 0; |
+ return false; |
} |
uint32_t SkValidatingReadBuffer::getArrayCount() { |