diff options
author | Moonchild <moonchild@palemoon.org> | 2022-03-08 21:12:18 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-05-30 08:17:20 +0000 |
commit | 8e42fccca66d06b664ecc3c7345dc787a26ef4d9 (patch) | |
tree | f7249df9b388c192b7b44c9947d868b156422f0a /image | |
parent | edd7cd7d870f97ba85f4c97b5d83d8e5e544bdc0 (diff) | |
download | uxp-8e42fccca66d06b664ecc3c7345dc787a26ef4d9.tar.gz |
[image] Add additional locks to imgFrame.
Diffstat (limited to 'image')
-rw-r--r-- | image/imgFrame.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/image/imgFrame.cpp b/image/imgFrame.cpp index 9a0846bce2..88cef68bf9 100644 --- a/image/imgFrame.cpp +++ b/image/imgFrame.cpp @@ -123,7 +123,7 @@ AllowedImageSize(int32_t aWidth, int32_t aHeight) return false; } - // check to make sure we don't overflow a 32-bit + // check to make sure we don't overflow 32-bit size for RGBA CheckedInt32 requiredBytes = CheckedInt32(aWidth) * CheckedInt32(aHeight) * 4; if (MOZ_UNLIKELY(!requiredBytes.isValid())) { NS_WARNING("width or height too large"); @@ -198,6 +198,7 @@ imgFrame::InitForDecoder(const nsIntSize& aImageSize, // warn for properties related to bad content. if (!AllowedImageAndFrameDimensions(aImageSize, aRect)) { NS_WARNING("Should have legal image size"); + MonitorAutoLock lock(mMonitor); mAborted = true; return NS_ERROR_FAILURE; } @@ -287,6 +288,7 @@ imgFrame::InitWithDrawable(gfxDrawable* aDrawable, // warn for properties related to bad content. if (!AllowedImageSize(aSize.width, aSize.height)) { NS_WARNING("Should have legal image size"); + MonitorAutoLock lock(mMonitor); mAborted = true; return NS_ERROR_FAILURE; } @@ -303,6 +305,7 @@ imgFrame::InitWithDrawable(gfxDrawable* aDrawable, gfxPlatform::GetPlatform()->CanRenderContentToDataSurface(); if (canUseDataSurface) { + MonitorAutoLock lock(mMonitor); // It's safe to use data surfaces for content on this platform, so we can // get away with using volatile buffers. MOZ_ASSERT(!mImageSurface, "Called imgFrame::InitWithDrawable() twice?"); @@ -344,7 +347,12 @@ imgFrame::InitWithDrawable(gfxDrawable* aDrawable, // surface instead. This means if someone later calls RawAccessRef(), we // may have to do an expensive readback, but we warned callers about that in // the documentation for this method. - MOZ_ASSERT(!mOptSurface, "Called imgFrame::InitWithDrawable() twice?"); +#ifdef DEBUG + { + MonitorAutoLock lock(mMonitor); + MOZ_ASSERT(!mOptSurface, "Called imgFrame::InitWithDrawable() twice?"); + } +#endif if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(aBackend)) { target = gfxPlatform::GetPlatform()-> @@ -356,6 +364,7 @@ imgFrame::InitWithDrawable(gfxDrawable* aDrawable, } if (!target || !target->IsValid()) { + MonitorAutoLock lock(mMonitor); mAborted = true; return NS_ERROR_OUT_OF_MEMORY; } @@ -367,6 +376,7 @@ imgFrame::InitWithDrawable(gfxDrawable* aDrawable, ImageRegion::Create(ThebesRect(mFrameRect)), mFormat, aSamplingFilter, aImageFlags); + MonitorAutoLock lock(mMonitor); if (canUseDataSurface && !mImageSurface) { NS_WARNING("Failed to create VolatileDataSourceSurface"); mAborted = true; @@ -383,10 +393,7 @@ imgFrame::InitWithDrawable(gfxDrawable* aDrawable, mDecoded = GetRect(); mFinished = true; -#ifdef DEBUG - MonitorAutoLock lock(mMonitor); MOZ_ASSERT(AreAllPixelsWritten()); -#endif return NS_OK; } |