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

Unified Diff: src/ports/SkFontConfigParser_android.cpp

Issue 925933003: Verify all parsed test font files start with cap. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment. Created 5 years, 10 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 | tests/FontConfigParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontConfigParser_android.cpp
diff --git a/src/ports/SkFontConfigParser_android.cpp b/src/ports/SkFontConfigParser_android.cpp
index ce4ebbeb41bee3dcb7d00cc3e365ad3e0161581d..eb2ed07f9e918f620c2b4f2feff9887a151a70a8 100644
--- a/src/ports/SkFontConfigParser_android.cpp
+++ b/src/ports/SkFontConfigParser_android.cpp
@@ -449,7 +449,8 @@ static int parse_config_file(const char* filename, SkTDArray<FontFamily*>& famil
// One would assume it would be faster to have a buffer on the stack and call XML_Parse.
// But XML_Parse will call XML_GetBuffer anyway and memmove the passed buffer into it.
// (Unless XML_CONTEXT_BYTES is undefined, but all users define it.)
- static const int bufferSize = 512;
+ // In debug, buffer a small odd number of bytes to detect slicing in XML_CharacterDataHandler.
+ static const int bufferSize = 512 SkDEBUGCODE( - 507);
bool done = false;
while (!done) {
void* buffer = XML_GetBuffer(parser, bufferSize);
@@ -508,10 +509,12 @@ static void append_fallback_font_families_for_locale(SkTDArray<FontFamily*>& fal
}
for (struct dirent* dirEntry; (dirEntry = readdir(fontDirectory));) {
- // The size of both the prefix, suffix, and a minimum valid language code
- static const size_t minSize = sizeof(LOCALE_FALLBACK_FONTS_PREFIX) - 1
- + sizeof(LOCALE_FALLBACK_FONTS_SUFFIX) - 1
- + 2;
+ // The size of the prefix and suffix.
+ static const size_t fixedLen = sizeof(LOCALE_FALLBACK_FONTS_PREFIX) - 1
+ + sizeof(LOCALE_FALLBACK_FONTS_SUFFIX) - 1;
+
+ // The size of the prefix, suffix, and a minimum valid language code
+ static const size_t minSize = fixedLen + 2;
SkString fileName(dirEntry->d_name);
if (fileName.size() < minSize ||
@@ -521,9 +524,6 @@ static void append_fallback_font_families_for_locale(SkTDArray<FontFamily*>& fal
continue;
}
- static const size_t fixedLen = sizeof(LOCALE_FALLBACK_FONTS_PREFIX) - 1
- + sizeof(LOCALE_FALLBACK_FONTS_SUFFIX) - 1;
-
SkString locale(fileName.c_str() + sizeof(LOCALE_FALLBACK_FONTS_PREFIX) - 1,
fileName.size() - fixedLen);
« no previous file with comments | « no previous file | tests/FontConfigParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698