aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2018-03-22 13:08:31 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-22 18:22:35 +0000
commit5b3de794171019fd6fbb3b847d2139a8758b31f7 (patch)
tree49c72c0f9716f2ab18dc327d8351a4900eb83e24 /src
parent327ef03a0120f2845b5d89bf04d5ea684bb27077 (diff)
lock before using fCacheKeys in ~SkImageFilter()
No other code can be using an SkImageFilter() while it's being destroyed, so there's not a chance of a race per-se here. But, because we have not acquired fMutex, there is technically a possibility that the destructor sees an outdated version of fCacheKeys, not necessarily reflecting the last change(s) made while another core held the mutex. This is an unlikely case, but it's worth fixing by locking in the destructor. This will always be uncontended, and so very cheap. Bug: skia:7666 Change-Id: I9f705bc6e8e99162b90d59b30b8dd51c4f238970 Reviewed-on: https://skia-review.googlesource.com/115929 Reviewed-by: Ben Wagner <benjaminwagner@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkImageFilter.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index ae3b53a69e..815a78260e 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -168,6 +168,7 @@ SkImageFilter::SkImageFilter(sk_sp<SkImageFilter> const* inputs,
}
SkImageFilter::~SkImageFilter() {
+ SkAutoMutexAcquire lock(fMutex);
SkImageFilterCache::Get()->purgeByKeys(fCacheKeys.begin(), fCacheKeys.count());
}