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

Unified Diff: src/core/SkGlyphCache.cpp

Issue 1333003002: Correct a possible free after use. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move purge code. Created 5 years, 3 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/core/SkGlyphCache_Globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkGlyphCache.cpp
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index add0ea9f00e83f4a8be41140fa32d062724b6473..61122048690d66d85aee8d832ec86d7e04b06022 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -428,12 +428,10 @@ SkGlyphCache* SkGlyphCache::VisitCache(
}
cache = new SkGlyphCache(typeface, desc, ctx);
-
- globals.attachCacheToHead(cache);
}
- AutoValidate av(cache);
AutoAcquire ac(globals.fLock);
mtklein 2015/09/10 20:35:47 Does this make sense? // Do not lock globals.fLoc
+ globals.internalAttachCacheToHead(cache);
cache->fMapMutex.acquireShared();
if (!proc(cache, context)) { // need to reattach
@@ -534,9 +532,8 @@ void SkGlyphCache::VisitAll(Visitor visitor, void* context) {
///////////////////////////////////////////////////////////////////////////////
-void SkGlyphCache_Globals::attachCacheToHead(SkGlyphCache* cache) {
- AutoAcquire ac(fLock);
-
+void SkGlyphCache_Globals::internalAttachCacheToHead(SkGlyphCache* cache) {
+ this->internalPurge();
fCacheCount += 1;
cache->fRefCount += 1;
// Access to cache->fMemoryUsed is single threaded until internalMoveToHead.
@@ -546,8 +543,6 @@ void SkGlyphCache_Globals::attachCacheToHead(SkGlyphCache* cache) {
this->validate();
cache->validate();
-
- this->internalPurge();
}
SkGlyphCache* SkGlyphCache_Globals::internalGetTail() const {
« no previous file with comments | « no previous file | src/core/SkGlyphCache_Globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698