commit 21bf65b55f3997385820ca4015eee74b607e06fa
parent ea7162586cdb9856bf687054064de252ad955730
Author: Lee Salzman <lsalzman@mozilla.com>
Date: Sun, 14 Dec 2025 22:33:15 +0000
Bug 2002074 - Ensure surface is unmapped before error exit. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D276381
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -6837,14 +6837,18 @@ void CanvasRenderingContext2D::PutImageData_explicit(
dirtyRect.Size());
});
- if (aRv.Failed()) {
- return;
- }
-
+ // Ensure surfaces unmapped before potential error exit.
if (lockedBits) {
mTarget->ReleaseBits(lockedBits);
} else if (sourceSurface) {
sourceSurface->Unmap();
+ }
+
+ if (aRv.Failed()) {
+ return;
+ }
+
+ if (sourceSurface) {
mTarget->CopySurface(sourceSurface, dirtyRect - dirtyRect.TopLeft(),
dirtyRect.TopLeft());
}