Bug 134426 Set image as wallpaper crashes Mozilla (when Mozilla Wallpaper.bmp is Read-Only)

r=timeless, sr=hewitt
return FAILURE instead of crashing when output stream can't be opend
This commit is contained in:
kyle.yuan%sun.com 2002-06-03 09:20:35 +00:00
Родитель d703b8275b
Коммит 3f2fc911e2
1 изменённых файлов: 12 добавлений и 10 удалений

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

@ -881,18 +881,20 @@ WriteBitmap(nsString& aPath, gfxIImageFrame* aImage)
// write the bitmap headers and rgb pixel data to the file
nsresult rv = NS_ERROR_FAILURE;
PRUint32 written;
stream->Write((const char*)&bf, sizeof(BITMAPFILEHEADER), &written);
if (written == sizeof(BITMAPFILEHEADER)) {
stream->Write((const char*)bmi, sizeof(BITMAPINFOHEADER), &written);
if (written == sizeof(BITMAPINFOHEADER)) {
stream->Write((const char*)bits, length, &written);
if (written == length)
rv = NS_OK;
if (stream) {
PRUint32 written;
stream->Write((const char*)&bf, sizeof(BITMAPFILEHEADER), &written);
if (written == sizeof(BITMAPFILEHEADER)) {
stream->Write((const char*)bmi, sizeof(BITMAPINFOHEADER), &written);
if (written == sizeof(BITMAPINFOHEADER)) {
stream->Write((const char*)bits, length, &written);
if (written == length)
rv = NS_OK;
}
}
}
stream->Close();
stream->Close();
}
return rv;
}