Correct a possible free after use.
This shows up in TSAN runs as a use-after-free warning. BUG=skia: Review URL: https://codereview.chromium.org/1333003002
This commit is contained in:
parent
a1c0ee4004
commit
83e599a7ab
@ -428,12 +428,10 @@ SkGlyphCache* SkGlyphCache::VisitCache(
|
||||
}
|
||||
|
||||
cache = new SkGlyphCache(typeface, desc, ctx);
|
||||
|
||||
globals.attachCacheToHead(cache);
|
||||
}
|
||||
|
||||
AutoValidate av(cache);
|
||||
AutoAcquire ac(globals.fLock);
|
||||
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 {
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
void purgeAll(); // does not change budget
|
||||
|
||||
// call when a glyphcache is available for caching (i.e. not in use)
|
||||
void attachCacheToHead(SkGlyphCache*);
|
||||
void internalAttachCacheToHead(SkGlyphCache*);
|
||||
|
||||
// can only be called when the mutex is already held
|
||||
void internalMoveToHead(SkGlyphCache *);
|
||||
|
Loading…
Reference in New Issue
Block a user