Fix fuzzer crash in SkReadBuffer::readTypeface()

BUG=skia:7398

Change-Id: I1d0f7a37c6f02ec5f621f7c1b5983b668530dcd9
Reviewed-on: https://skia-review.googlesource.com/83561
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
Florin Malita 2017-12-11 15:22:15 -05:00 committed by Skia Commit-Bot
parent 7fdd862512
commit bb091a08d1

View File

@ -392,7 +392,7 @@ sk_sp<SkTypeface> SkReadBuffer::readTypeface() {
} else { // custom
size_t size = sk_negate_to_size_t(index);
const void* data = this->skip(size);
if (!this->validate(data != nullptr)) {
if (!this->validate(data != nullptr && fProcs.fTypefaceProc)) {
return nullptr;
}
return fProcs.fTypefaceProc(data, size, fProcs.fTypefaceCtx);