summaryrefslogtreecommitdiffstats
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
commit3a8b4ad00ad6cffba1129fcb23c926a7a924cbfa (patch)
treebe6cac4b2df46d65ee2be3d973d477661da86258
parentc1dd23bd83eddaa5e7908f90775da949c96afd8a (diff)
downloadUXP-3a8b4ad00ad6cffba1129fcb23c926a7a924cbfa.tar
UXP-3a8b4ad00ad6cffba1129fcb23c926a7a924cbfa.tar.gz
UXP-3a8b4ad00ad6cffba1129fcb23c926a7a924cbfa.tar.lz
UXP-3a8b4ad00ad6cffba1129fcb23c926a7a924cbfa.tar.xz
UXP-3a8b4ad00ad6cffba1129fcb23c926a7a924cbfa.zip
Fix rooting hazard in ImageBitmap::CreateInternal by avoiding movable data.
-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,