diff options
author | Moonchild <moonchild@palemoon.org> | 2021-01-26 11:49:35 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-01-26 11:49:35 +0000 |
commit | 3a8b4ad00ad6cffba1129fcb23c926a7a924cbfa (patch) | |
tree | be6cac4b2df46d65ee2be3d973d477661da86258 /dom/canvas | |
parent | c1dd23bd83eddaa5e7908f90775da949c96afd8a (diff) | |
download | uxp-3a8b4ad00ad6cffba1129fcb23c926a7a924cbfa.tar.gz |
Fix rooting hazard in ImageBitmap::CreateInternal by avoiding movable data.
Diffstat (limited to 'dom/canvas')
-rw-r--r-- | dom/canvas/ImageBitmap.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp index e4b145d461..bb47618a63 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, |