Index: src/core/SkValidatingReadBuffer.cpp |
diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp |
index 9f094f9617f1161361452a3b8d56a6d285967a92..3084565ffdee978edb187affcb40ecdb302b3a4c 100644 |
--- a/src/core/SkValidatingReadBuffer.cpp |
+++ b/src/core/SkValidatingReadBuffer.cpp |
@@ -118,8 +118,11 @@ void SkValidatingReadBuffer::readPoint(SkPoint* point) { |
} |
void SkValidatingReadBuffer::readMatrix(SkMatrix* matrix) { |
- const size_t size = matrix->readFromMemory(fReader.peek()); |
- this->validate(SkAlign4(size) == size); |
+ size_t size = 0; |
+ if (!fError) { |
+ size = matrix->readFromMemory(fReader.peek(), fReader.available()); |
+ this->validate((SkAlign4(size) != size) || (0 == size)); |
+ } |
if (!fError) { |
(void)this->skip(size); |
} |
@@ -140,16 +143,22 @@ void SkValidatingReadBuffer::readRect(SkRect* rect) { |
} |
void SkValidatingReadBuffer::readRegion(SkRegion* region) { |
- const size_t size = region->readFromMemory(fReader.peek()); |
- this->validate(SkAlign4(size) == size); |
+ size_t size = 0; |
+ if (!fError) { |
+ size = region->readFromMemory(fReader.peek(), fReader.available()); |
+ this->validate((SkAlign4(size) != size) || (0 == size)); |
+ } |
if (!fError) { |
(void)this->skip(size); |
} |
} |
void SkValidatingReadBuffer::readPath(SkPath* path) { |
- const size_t size = path->readFromMemory(fReader.peek()); |
- this->validate(SkAlign4(size) == size); |
+ size_t size = 0; |
+ if (!fError) { |
+ size = path->readFromMemory(fReader.peek(), fReader.available()); |
+ this->validate((SkAlign4(size) != size) || (0 == size)); |
+ } |
if (!fError) { |
(void)this->skip(size); |
} |
@@ -189,6 +198,8 @@ bool SkValidatingReadBuffer::readScalarArray(SkScalar* values, size_t size) { |
} |
uint32_t SkValidatingReadBuffer::getArrayCount() { |
+ const size_t inc = sizeof(uint32_t); |
+ fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc); |
return *(uint32_t*)fReader.peek(); |
} |