Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/Font.cpp

Issue 2110703002: Harden a security CHECK in Font::individualCharacterRanges (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 Vector<CharacterRange> Font::individualCharacterRanges(const TextRun& run) const 766 Vector<CharacterRange> Font::individualCharacterRanges(const TextRun& run) const
767 { 767 {
768 // TODO(pdr): Android is temporarily (crbug.com/577306) using the old simple 768 // TODO(pdr): Android is temporarily (crbug.com/577306) using the old simple
769 // shaper and using the complex shaper here can show differences between 769 // shaper and using the complex shaper here can show differences between
770 // the two shapers. This function is currently only called through SVG 770 // the two shapers. This function is currently only called through SVG
771 // which now exclusively uses the complex shaper, so the primary difference 771 // which now exclusively uses the complex shaper, so the primary difference
772 // will be improved shaping in SVG when compared to HTML. 772 // will be improved shaping in SVG when compared to HTML.
773 FontCachePurgePreventer purgePreventer; 773 FontCachePurgePreventer purgePreventer;
774 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription)); 774 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription));
775 auto ranges = shaper.individualCharacterRanges(this, run); 775 auto ranges = shaper.individualCharacterRanges(this, run);
776 DCHECK_EQ(ranges.size(), run.length()); 776 // The shaper should return ranges.size == run.length but on some platforms
777 // (OSX10.9.5) we are seeing cases in the upper end of the unicode range
778 // where this is not true (see: crbug.com/620952). To catch these cases on
779 // more popular platforms, and to protect users, we are using a CHECK here.
780 CHECK_EQ(ranges.size(), run.length());
777 return ranges; 781 return ranges;
778 } 782 }
779 783
780 float Font::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFont Data*>* fallbackFonts, FloatRect* glyphBounds) const 784 float Font::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFont Data*>* fallbackFonts, FloatRect* glyphBounds) const
781 { 785 {
782 SimpleShaper shaper(this, run, nullptr, fallbackFonts, glyphBounds); 786 SimpleShaper shaper(this, run, nullptr, fallbackFonts, glyphBounds);
783 shaper.advance(run.length()); 787 shaper.advance(run.length());
784 return shaper.runWidthSoFar(); 788 return shaper.runWidthSoFar();
785 } 789 }
786 790
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 { 858 {
855 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); 859 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts();
856 } 860 }
857 861
858 bool Font::isFallbackValid() const 862 bool Font::isFallbackValid() const
859 { 863 {
860 return !m_fontFallbackList || m_fontFallbackList->isValid(); 864 return !m_fontFallbackList || m_fontFallbackList->isValid();
861 } 865 }
862 866
863 } // namespace blink 867 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698