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

Unified Diff: content/common/dwrite_font_platform_win.cc

Issue 733253005: Added few validations in Direct Write Font Cache code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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: content/common/dwrite_font_platform_win.cc
diff --git a/content/common/dwrite_font_platform_win.cc b/content/common/dwrite_font_platform_win.cc
index 5d56ce4b55549cf41cbca6d840421b801ff1961f..7479c6717c02ff97f57f6dcaf06ea7cd3203ac35 100644
--- a/content/common/dwrite_font_platform_win.cc
+++ b/content/common/dwrite_font_platform_win.cc
@@ -281,13 +281,10 @@ class FontCacheWriter {
// Function to create static font cache file.
bool Create(const wchar_t* file_name) {
static_cache_.reset(new base::File(base::FilePath(file_name),
- base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE));
+ base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE |
+ base::File::FLAG_EXCLUSIVE_WRITE));
if (!static_cache_->IsValid()) {
static_cache_.reset();
- // TODO(shrikant): Convert this CHECK to DCHECK post canary.
- // We have all fallbacks built in, so if we are not able to create
- // static cache, browser can still run with old way of loading all fonts.
- CHECK(FALSE);
return false;
}
CacheFileHeader header;
@@ -911,8 +908,8 @@ bool FontCollectionLoader::LoadCacheFile() {
void FontCollectionLoader::EnterStaticCacheMode(const WCHAR* file_name) {
cache_writer_.reset(new FontCacheWriter());
- cache_writer_->Create(file_name);
- create_static_cache_ = true;
+ if (cache_writer_->Create(file_name))
+ create_static_cache_ = true;
}
void FontCollectionLoader::LeaveStaticCacheMode() {
@@ -956,7 +953,9 @@ bool FontCollectionLoader::ValidateAndLoadCacheMap() {
table_entry = iter->second;
}
table_entry->file_size = entry->file_size;
- for (DWORD idx = 0; current_ptr < mem_file_end && idx < entry->entry_count;
+ for (DWORD idx = 0;
+ (current_ptr + sizeof(CacheFileOffsetEntry)) < mem_file_end &&
+ idx < entry->entry_count;
idx++) {
CacheFileOffsetEntry* offset_entry =
reinterpret_cast<CacheFileOffsetEntry*>(current_ptr);
« 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