Commit c813f317 authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Avoid accessing empty SkData when retrieving matched font blob

When attempting to match a font from Android downloadable fonts, there
is a scenario in which no font can be created from the returned file
descriptor. Check for null SkData before testing for isEmpty()

Bug: 1127513
Change-Id: Icaa8e6fadfca6750e9eccb78e6d20c5de20c7f02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429272Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811228}
parent d040c14e
...@@ -186,7 +186,7 @@ FontUniqueNameLookupAndroid::MatchUniqueNameFromDownloadableFonts( ...@@ -186,7 +186,7 @@ FontUniqueNameLookupAndroid::MatchUniqueNameFromDownloadableFonts(
sk_sp<SkData> font_data = SkData::MakeFromFD(font_file.GetPlatformFile()); sk_sp<SkData> font_data = SkData::MakeFromFD(font_file.GetPlatformFile());
if (font_data->isEmpty()) { if (!font_data || font_data->isEmpty()) {
LOG(ERROR) << "Received file descriptor has 0 size."; LOG(ERROR) << "Received file descriptor has 0 size.";
lookup_latency_histogram_failure.CountMicroseconds(elapsed_timer.Elapsed()); lookup_latency_histogram_failure.CountMicroseconds(elapsed_timer.Elapsed());
return nullptr; return nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment