Bug 1074192 - Hold the mutex in imgFrame when creating a DrawableFrameRef; r?tnikkel draft
authorAndrew Osmond <aosmond@gmail.com>
Wed, 15 Mar 2017 09:43:49 -0400
changeset 499299 0eb566f14cabbdd1f34ee20f7e34509e240f1d1e
parent 499298 323c768fdc43287396120b29a0c29f6bdcbef232
child 549296 60b2bac4a3aed768c9c3405f1952895cb15d5394
push id49353
push userbmo:aosmond@mozilla.com
push dateWed, 15 Mar 2017 14:20:46 +0000
reviewerstnikkel
bugs1074192
milestone55.0a1
Bug 1074192 - Hold the mutex in imgFrame when creating a DrawableFrameRef; r?tnikkel MozReview-Commit-ID: 5G4bQdLAhgC
image/imgFrame.h
--- a/image/imgFrame.h
+++ b/image/imgFrame.h
@@ -473,16 +473,19 @@ class DrawableFrameRef final
   typedef gfx::DataSourceSurface DataSourceSurface;
 
 public:
   DrawableFrameRef() { }
 
   explicit DrawableFrameRef(imgFrame* aFrame)
     : mFrame(aFrame)
   {
+    MOZ_ASSERT(aFrame);
+    MonitorAutoLock lock(aFrame->mMonitor);
+
     // Paletted images won't have a surface so there is no strong reference
     // to hold on to. Since Draw() and GetSourceSurface() calls will not work
     // in that case, we should be using RawAccessFrameRef exclusively instead.
     // See FrameAnimator::GetRawFrame for an example of this behaviour.
     if (aFrame->mRawSurface) {
       mRef = new DataSourceSurface::ScopedMap(aFrame->mRawSurface,
                                               DataSourceSurface::READ_WRITE);
       if (!mRef->IsMapped()) {