Bug 1641578: Avoid crashing when Recorded surface or font storage fail to allocate. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D77271
This commit is contained in:
Bob Owen 2020-05-28 18:05:53 +00:00
Родитель fece288de8
Коммит c6e63b484f
1 изменённых файлов: 9 добавлений и 3 удалений

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

@ -3068,6 +3068,7 @@ RecordedSourceSurfaceCreation::RecordedSourceSurfaceCreation(S& aStream)
gfxCriticalNote
<< "RecordedSourceSurfaceCreation failed to allocate data of size "
<< size;
aStream.SetIsBad();
} else {
aStream.read((char*)mData, size);
}
@ -3425,8 +3426,12 @@ void RecordedFontData::Record(S& aStream) const {
WriteElement(aStream, mType);
WriteElement(aStream, mFontDetails.fontDataKey);
WriteElement(aStream, mFontDetails.size);
aStream.write((const char*)mData, mFontDetails.size);
if (!mData) {
WriteElement(aStream, 0);
} else {
WriteElement(aStream, mFontDetails.size);
aStream.write((const char*)mData, mFontDetails.size);
}
}
inline void RecordedFontData::OutputSimpleEventInfo(
@ -3466,7 +3471,7 @@ RecordedFontData::RecordedFontData(S& aStream)
ReadElementConstrained(aStream, mType, FontType::DWRITE, FontType::UNKNOWN);
ReadElement(aStream, mFontDetails.fontDataKey);
ReadElement(aStream, mFontDetails.size);
if (!aStream.good()) {
if (!mFontDetails.size || !aStream.good()) {
return;
}
@ -3475,6 +3480,7 @@ RecordedFontData::RecordedFontData(S& aStream)
gfxCriticalNote
<< "RecordedFontData failed to allocate data for playback of size "
<< mFontDetails.size;
aStream.SetIsBad();
} else {
aStream.read((char*)mData, mFontDetails.size);
}