Skip to content

Commit 92dc1a6

Browse files
[skia-sync] Merge upstream chrome/m153 bug fixes (#350)
[skia-sync] Merge upstream chrome/m153 bug fixes (#350) Requires: mono/SkiaSharp#4927 Changes: ca4e52c...d87457d Merge the Chrome M153 use-after-free fix into the SkiaSharp fork. SkCachedData::internalUnref could delete its owning object before the AutoMutexWritable guard released the object's mutex. Store the unref result, destroy the guard, and only then delete the object, preventing the mutex from being unlocked through freed memory. The reviewed range changes only src/core/SkCachedData.cpp and requires no fork conflict resolution. Preserve its two-parent ancestry by selecting **Create a merge commit**; do not squash or rebase this PR. Co-authored-by: Arthur Sonzogni <arthursonzogni@chromium.org> Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
2 parents ca4e52c + d87457d commit 92dc1a6

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/core/SkCachedData.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ void SkCachedData::internalRef(bool fromCache) const {
6565
}
6666

6767
void SkCachedData::internalUnref(bool fromCache) const {
68-
if (AutoMutexWritable(this)->inMutexUnref(fromCache)) {
68+
bool shouldDelete = false;
69+
{
70+
AutoMutexWritable amw(this);
71+
shouldDelete = amw->inMutexUnref(fromCache);
72+
}
73+
if (shouldDelete) {
6974
// can't delete inside doInternalUnref, since it is locking a mutex (which we own)
7075
delete this;
7176
}

0 commit comments

Comments
 (0)