init out-param on buffer failure

Bug:804651
Change-Id: Ia3c71e2fbe35b55bf27075e6a11ec8c5bd3fb40f
Reviewed-on: https://skia-review.googlesource.com/98663
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-01-23 12:34:56 -05:00 committed by Skia Commit-Bot
parent 959ccc2aef
commit 574b06f703

View File

@ -182,7 +182,9 @@ void SkReadBuffer::readMatrix(SkMatrix* matrix) {
size_t size = 0;
if (this->isValid()) {
size = SkMatrixPriv::ReadFromMemory(matrix, fReader.peek(), fReader.available());
this->validate((SkAlign4(size) == size) && (0 != size));
if (!this->validate((SkAlign4(size) == size) && (0 != size))) {
matrix->reset();
}
}
(void)this->skip(size);
}
@ -209,7 +211,9 @@ void SkReadBuffer::readRegion(SkRegion* region) {
size_t size = 0;
if (!fError) {
size = region->readFromMemory(fReader.peek(), fReader.available());
this->validate((SkAlign4(size) == size) && (0 != size));
if (!this->validate((SkAlign4(size) == size) && (0 != size))) {
region->setEmpty();
}
}
(void)this->skip(size);
}
@ -218,7 +222,9 @@ void SkReadBuffer::readPath(SkPath* path) {
size_t size = 0;
if (!fError) {
size = path->readFromMemory(fReader.peek(), fReader.available());
this->validate((SkAlign4(size) == size) && (0 != size));
if (!this->validate((SkAlign4(size) == size) && (0 != size))) {
path->reset();
}
}
(void)this->skip(size);
}