check if stream failed

If so, index might be uninitialized, so don't use it

Bug: skia:
Change-Id: Icccf6c796cf73317f10c80d6f7523479662c401f
Reviewed-on: https://skia-review.googlesource.com/151221
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-09-03 14:59:39 -04:00 committed by Skia Commit-Bot
parent 2c55d8f5ee
commit 24e58341fb

View File

@ -271,6 +271,9 @@ std::unique_ptr<SkFontData> SkTypeface::makeFontData() const {
std::unique_ptr<SkFontData> SkTypeface::onMakeFontData() const {
int index;
std::unique_ptr<SkStreamAsset> stream(this->onOpenStream(&index));
if (!stream) {
return nullptr;
}
return skstd::make_unique<SkFontData>(std::move(stream), index, nullptr, 0);
};