fix writeImage when encode step fails, since data is null

Bug: skia:
Change-Id: Ifdfeba4b6d46a3169f60f3494245cf5abefe4c4a
Reviewed-on: https://skia-review.googlesource.com/113743
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-03-12 12:50:54 -04:00 committed by Skia Commit-Bot
parent d34c633442
commit 061c27825d

View File

@ -150,8 +150,10 @@ void SkBinaryWriteBuffer::writeImage(const SkImage* image) {
if (!sk_64_isS32(size)) {
size = 0; // too big to store
}
this->write32(SkToS32(size)); // writing 0 signals failure
this->writePad32(data->data(), size); // does nothing if size == 0
this->write32(SkToS32(size)); // writing 0 signals failure
if (size) {
this->writePad32(data->data(), size);
}
}
void SkBinaryWriteBuffer::writeTypeface(SkTypeface* obj) {