Bug 1415081 - part 7 - Fix the use of NS_ReadInputStreamToString in HTMLCanvasElement, r=smaug

This commit is contained in:
Andrea Marchesini 2017-11-09 11:18:09 +01:00
Родитель fbd0acbfa7
Коммит fc0aff8605
1 изменённых файлов: 2 добавлений и 7 удалений

Просмотреть файл

@ -961,20 +961,15 @@ HTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName,
NS_ENSURE_SUCCESS(rv, rv);
uint64_t imgSize;
rv = stream->Available(&imgSize);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(imgSize <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
void* imgData = nullptr;
rv = NS_ReadInputStreamToBuffer(stream, &imgData, (uint32_t)imgSize);
rv = NS_ReadInputStreamToBuffer(stream, &imgData, -1, &imgSize);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(OwnerDoc()->GetScopeObject());
// The File takes ownership of the buffer
RefPtr<File> file =
File::CreateMemoryFile(win, imgData, (uint32_t)imgSize, aName, type,
PR_Now());
File::CreateMemoryFile(win, imgData, imgSize, aName, type, PR_Now());
file.forget(aResult);
return NS_OK;