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

Unified Diff: src/ports/SkFontConfigInterface_android.cpp

Issue 226183002: Prevent potential leaking of memory by using SkString and SkTArray. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 | src/ports/SkFontConfigParser_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontConfigInterface_android.cpp
diff --git a/src/ports/SkFontConfigInterface_android.cpp b/src/ports/SkFontConfigInterface_android.cpp
index 14be93457f1b1a25fbfa21028bd5a1d9364b5b98..20e6c5eb84b6270b4b93b9979985e575d27f848c 100644
--- a/src/ports/SkFontConfigInterface_android.cpp
+++ b/src/ports/SkFontConfigInterface_android.cpp
@@ -174,7 +174,7 @@ static bool has_font(const SkTArray<FontRec>& array, const SkString& filename) {
#define SK_FONT_FILE_PREFIX "/fonts/"
#endif
-static void get_path_for_sys_fonts(SkString* full, const char name[]) {
+static void get_path_for_sys_fonts(SkString* full, const SkString& name) {
if (gTestFontFilePrefix) {
full->set(gTestFontFilePrefix);
} else {
@@ -220,7 +220,7 @@ SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*
for (int j = 0; j < family->fFontFiles.count(); ++j) {
SkString filename;
- get_path_for_sys_fonts(&filename, family->fFontFiles[j]->fFileName);
+ get_path_for_sys_fonts(&filename, family->fFontFiles[j].fFileName);
if (has_font(fFonts, filename)) {
SkDebugf("---- system font and fallback font files specify a duplicate "
@@ -265,9 +265,9 @@ SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*
fontRec.fFamilyRecID = familyRecID;
familyRec->fIsFallbackFont = family->fIsFallbackFont;
- familyRec->fPaintOptions = family->fFontFiles[j]->fPaintOptions;
+ familyRec->fPaintOptions = family->fFontFiles[j].fPaintOptions;
- } else if (familyRec->fPaintOptions != family->fFontFiles[j]->fPaintOptions) {
+ } else if (familyRec->fPaintOptions != family->fFontFiles[j].fPaintOptions) {
SkDebugf("Every font file within a family must have identical"
"language and variant attributes");
sk_throw();
@@ -289,14 +289,14 @@ SkFontConfigInterfaceAndroid::SkFontConfigInterfaceAndroid(SkTDArray<FontFamily*
addFallbackFamily(familyRecID);
} else {
// add the names that map to this family to the dictionary for easy lookup
- const SkTDArray<const char*>& names = family->fNames;
- if (names.isEmpty()) {
+ const SkTArray<SkString>& names = family->fNames;
+ if (names.empty()) {
SkDEBUGFAIL("ERROR: non-fallback font with no name");
continue;
}
for (int i = 0; i < names.count(); i++) {
- insert_into_name_dict(fFamilyNameDict, names[i], familyRecID);
+ insert_into_name_dict(fFamilyNameDict, names[i].c_str(), familyRecID);
}
}
}
« no previous file with comments | « no previous file | src/ports/SkFontConfigParser_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698