diff --git a/src/core/SkCachedData.cpp b/src/core/SkCachedData.cpp index b48bee85060..6df6d1d9229 100644 --- a/src/core/SkCachedData.cpp +++ b/src/core/SkCachedData.cpp @@ -65,7 +65,12 @@ void SkCachedData::internalRef(bool fromCache) const { } void SkCachedData::internalUnref(bool fromCache) const { - if (AutoMutexWritable(this)->inMutexUnref(fromCache)) { + bool shouldDelete = false; + { + AutoMutexWritable amw(this); + shouldDelete = amw->inMutexUnref(fromCache); + } + if (shouldDelete) { // can't delete inside doInternalUnref, since it is locking a mutex (which we own) delete this; }