Fix rooting hazard in ImageBitmap::CreateInternal by avoiding movable data.

master
Fedor 2021-02-07 17:33:27 +02:00
parent 8a7d4550aa
commit 7040645be7
1 changed files with 6 additions and 2 deletions

View File

@ -952,13 +952,17 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageData& aImageData,
// Create and Crop the raw data into a layers::Image // Create and Crop the raw data into a layers::Image
RefPtr<layers::Image> data; 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()) { if (NS_IsMainThread()) {
data = CreateImageFromRawData(imageSize, imageStride, FORMAT, data = CreateImageFromRawData(imageSize, imageStride, FORMAT,
array.Data(), dataLength, fixedData, dataLength,
aCropRect); aCropRect);
} else { } else {
RefPtr<CreateImageFromRawDataInMainThreadSyncTask> task RefPtr<CreateImageFromRawDataInMainThreadSyncTask> task
= new CreateImageFromRawDataInMainThreadSyncTask(array.Data(), = new CreateImageFromRawDataInMainThreadSyncTask(fixedData,
dataLength, dataLength,
imageStride, imageStride,
FORMAT, FORMAT,