summaryrefslogtreecommitdiff
path: root/dom/canvas/ImageBitmap.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-01-26 11:49:35 +0000
committerMoonchild <moonchild@palemoon.org>2021-01-26 11:49:35 +0000
commit67cdb962f00b00a2e1d5c4ca6b270d22cf494566 (patch)
treebe6cac4b2df46d65ee2be3d973d477661da86258 /dom/canvas/ImageBitmap.cpp
parenta1cb5692632872e554586a48d04c151e54a4f7f7 (diff)
downloadaura-central-67cdb962f00b00a2e1d5c4ca6b270d22cf494566.tar.gz
Fix rooting hazard in ImageBitmap::CreateInternal by avoiding movable data.
Diffstat (limited to 'dom/canvas/ImageBitmap.cpp')
-rw-r--r--dom/canvas/ImageBitmap.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
index e4b145d46..bb47618a6 100644
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -952,13 +952,17 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageData& aImageData,
// Create and Crop the raw data into a layers::Image
RefPtr<layers::Image> data;
+
+ // The data could move during a GC; copy it out into a local buffer.
+ uint8_t* fixedData = array.Data();
+
if (NS_IsMainThread()) {
data = CreateImageFromRawData(imageSize, imageStride, FORMAT,
- array.Data(), dataLength,
+ fixedData, dataLength,
aCropRect);
} else {
RefPtr<CreateImageFromRawDataInMainThreadSyncTask> task
- = new CreateImageFromRawDataInMainThreadSyncTask(array.Data(),
+ = new CreateImageFromRawDataInMainThreadSyncTask(fixedData,
dataLength,
imageStride,
FORMAT,