Index: src/core/SkValidatingReadBuffer.cpp |
diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp |
index a0e1a4179f2cd18ff431203aa8b1091102a68ec7..07d68586138c9224ff19581a299265e6a7ab746a 100644 |
--- a/src/core/SkValidatingReadBuffer.cpp |
+++ b/src/core/SkValidatingReadBuffer.cpp |
@@ -113,8 +113,8 @@ void SkValidatingReadBuffer::readPoint(SkPoint* point) { |
} |
void SkValidatingReadBuffer::readMatrix(SkMatrix* matrix) { |
- const size_t size = matrix->readFromMemory(fReader.peek()); |
- fError = fError || (SkAlign4(size) != size); |
+ const size_t size = matrix->readFromMemory(fReader.peek(), fReader.available()); |
+ fError = fError || (SkAlign4(size) != size) || (0 == size); |
if (!fError) { |
(void)this->skip(size); |
} |
@@ -135,16 +135,16 @@ void SkValidatingReadBuffer::readRect(SkRect* rect) { |
} |
void SkValidatingReadBuffer::readRegion(SkRegion* region) { |
- const size_t size = region->readFromMemory(fReader.peek()); |
- fError = fError || (SkAlign4(size) != size); |
+ const size_t size = region->readFromMemory(fReader.peek(), fReader.available()); |
+ fError = fError || (SkAlign4(size) != size) || (0 == size); |
if (!fError) { |
(void)this->skip(size); |
} |
} |
void SkValidatingReadBuffer::readPath(SkPath* path) { |
- const size_t size = path->readFromMemory(fReader.peek()); |
- fError = fError || (SkAlign4(size) != size); |
+ const size_t size = path->readFromMemory(fReader.peek(), fReader.available()); |
+ fError = fError || (SkAlign4(size) != size) || (0 == size); |
if (!fError) { |
(void)this->skip(size); |
} |
@@ -205,6 +205,8 @@ uint32_t SkValidatingReadBuffer::readScalarArray(SkScalar* values) { |
} |
uint32_t SkValidatingReadBuffer::getArrayCount() { |
+ const size_t inc = sizeof(uint32_t); |
+ fError = fError || !IsPtrAlign4(fReader.peek()) || !fReader.isAvailable(inc); |
return *(uint32_t*)fReader.peek(); |
} |