Fix DiscardableMemoryPool::free race condition

BUG=skia:3596

Review URL: https://codereview.chromium.org/1017943003
This commit is contained in:
halcanary 2015-03-26 14:08:56 -07:00 committed by Commit bot
parent a644116c33
commit 2edf599eeb

View File

@ -188,9 +188,9 @@ SkDiscardableMemory* DiscardableMemoryPool::create(size_t bytes) {
}
void DiscardableMemoryPool::free(PoolDiscardableMemory* dm) {
SkAutoMutexAcquire autoMutexAcquire(fMutex);
// This is called by dm's destructor.
if (dm->fPointer != NULL) {
SkAutoMutexAcquire autoMutexAcquire(fMutex);
sk_free(dm->fPointer);
dm->fPointer = NULL;
SkASSERT(fUsed >= dm->fBytes);