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

Unified Diff: src/ports/SkFontHost_FreeType.cpp

Issue 1900193002: SkFontHost/FreeType/ToUnicode: add an assert (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-04-20 (Wednesday) 11:05:56 EDT Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_FreeType.cpp
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 55eb87fe6d4bfadb8eadfaf01ec78128e5981855..3b1a5b207dca4c59c2c845f6f37310043398c410 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -445,12 +445,14 @@ static bool getWidthAdvance(FT_Face face, int gId, int16_t* data) {
}
static void populate_glyph_to_unicode(FT_Face& face, SkTDArray<SkUnichar>* glyphToUnicode) {
- glyphToUnicode->setCount(face->num_glyphs);
- sk_bzero(glyphToUnicode->begin(), sizeof((*glyphToUnicode)[0]) * face->num_glyphs);
+ FT_Long numGlyphs = face->num_glyphs;
+ glyphToUnicode->setCount(SkToInt(numGlyphs));
+ sk_bzero(glyphToUnicode->begin(), sizeof((*glyphToUnicode)[0]) * numGlyphs);
FT_UInt glyphIndex;
SkUnichar charCode = FT_Get_First_Char(face, &glyphIndex);
while (glyphIndex) {
+ SkASSERT(glyphIndex < SkToUInt(numGlyphs));
(*glyphToUnicode)[glyphIndex] = charCode;
charCode = FT_Get_Next_Char(face, charCode, &glyphIndex);
}
« 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