Commit 888beef6 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Avoid deferencing null pointer when calling GetFirstMatchingFont

The call to GetFirstMatchingFont(...) may fail. The matched_font will
be unset and can be null.

As stated on the doc: https://docs.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-idwritefontfamily-getfirstmatchingfont
The return value may be fail.
  Type: HRESULT
  If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

StackFrame:
  content::FontFallback::GetCachedFont(std::__1::basic_string<wchar_t,std::__1::char_traits<wchar_t>,std::__1::allocator<wchar_t> > const &,wchar_t const *,wchar_t const *,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,IDWriteFont * *,unsigned int *)
  content::FontFallback::MapCharacters(IDWriteTextAnalysisSource *,unsigned int,unsigned int,IDWriteFontCollection *,wchar_t const *,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,unsigned int *,IDWriteFont * *,float *)
  SkFontMgr_DirectWrite::fallback(wchar_t const *,DWriteStyle,wchar_t const *,unsigned int)
  SkFontMgr_DirectWrite::onMatchFamilyStyleCharacter(char const * const,SkFontStyle const &,char const * * const,int,int)
  blink::FontCache::GetDWriteFallbackFamily(blink::FontDescription const &,int,blink::FontFallbackPriority)
  blink::FontCache::PlatformFallbackFontForCharacter(blink::FontDescription const &,int,blink::SimpleFontData const *,blink::FontFallbackPriority)
  blink::FontCache::FallbackFontForCharacter(blink::FontDescription const &,int,blink::S

R=drott@chromium.org, fdoray@chromium.org
CC=eae@chromium.org

Bug: 997081
Change-Id: I3c007f3a7d9bba5dba78ae1a5e1eaaa7f8e8a7e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1814703Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698400}
parent df5cb101
...@@ -182,8 +182,12 @@ bool FontFallback::GetCachedFont(const base::string16& text, ...@@ -182,8 +182,12 @@ bool FontFallback::GetCachedFont(const base::string16& text,
for (family_iterator = family_list.begin(); for (family_iterator = family_list.begin();
family_iterator != family_list.end(); ++family_iterator) { family_iterator != family_list.end(); ++family_iterator) {
mswr::ComPtr<IDWriteFont> matched_font; mswr::ComPtr<IDWriteFont> matched_font;
(*family_iterator)->GetFirstMatchingFont(base_weight, base_stretch,
base_style, &matched_font); if (FAILED((*family_iterator)
->GetFirstMatchingFont(base_weight, base_stretch, base_style,
&matched_font))) {
continue;
}
// |character_index| tracks how much of the string we have read. This is // |character_index| tracks how much of the string we have read. This is
// different from |mapped_length| because ReadUnicodeCharacter can advance // different from |mapped_length| because ReadUnicodeCharacter can advance
......
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