From c371700a13d19f0ac62063ca0229d3e36e4cd4dd Mon Sep 17 00:00:00 2001 From: George Wright Date: Fri, 6 Jun 2014 14:26:21 -0400 Subject: [PATCH] Bug 913805 - Hold a lock on the RasterImage in ScaleRequest so that the srcFrame doesn't go away if we need to discard images to free up memory r=seth --- image/src/RasterImage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index d2ebf5c03cd7..6d19e49ca270 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -211,13 +211,16 @@ public: bool success = false; if (!dstLocked) { + // We need to hold a lock onto the RasterImage object itself so that + // it (and its associated imgFrames) aren't marked as discardable. + bool imgLocked = NS_SUCCEEDED(image->LockImage()); bool srcLocked = NS_SUCCEEDED(srcFrame->LockImageData()); srcSurface = srcFrame->GetSurface(); dstLocked = NS_SUCCEEDED(dstFrame->LockImageData()); dstSurface = dstFrame->GetSurface(); - success = srcLocked && dstLocked && srcSurface && dstSurface; + success = imgLocked && srcLocked && dstLocked && srcSurface && dstSurface; if (success) { srcData = srcFrame->GetImageData(); @@ -253,6 +256,7 @@ public: if (DiscardingEnabled()) dstFrame->SetDiscardable(); success = NS_SUCCEEDED(dstFrame->UnlockImageData()); + success = success && NS_SUCCEEDED(image->UnlockImage()); dstLocked = false; srcData = nullptr;