mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 05:48:26 +00:00
Bug 1556481 - check for DWrite failures in UnscaledFontDWrite::GetFontFileData. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D33585 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
9707b986e3
commit
9b48977698
@ -270,9 +270,9 @@ void ScaledFontDWrite::CopyGlyphsToSink(const GlyphBuffer& aBuffer,
|
||||
bool UnscaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback,
|
||||
void* aBaton) {
|
||||
UINT32 fileCount = 0;
|
||||
mFontFace->GetFiles(&fileCount, nullptr);
|
||||
HRESULT hr = mFontFace->GetFiles(&fileCount, nullptr);
|
||||
|
||||
if (fileCount > 1) {
|
||||
if (FAILED(hr) || fileCount > 1) {
|
||||
MOZ_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
@ -282,7 +282,10 @@ bool UnscaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback,
|
||||
}
|
||||
|
||||
RefPtr<IDWriteFontFile> file;
|
||||
mFontFace->GetFiles(&fileCount, getter_AddRefs(file));
|
||||
hr = mFontFace->GetFiles(&fileCount, getter_AddRefs(file));
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const void* referenceKey;
|
||||
UINT32 refKeySize;
|
||||
@ -290,17 +293,26 @@ bool UnscaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback,
|
||||
// key out of the file, that can be an invalid reference key for the loader
|
||||
// we use it with. The fix to this is not obvious but it will probably
|
||||
// have to happen inside thebes.
|
||||
file->GetReferenceKey(&referenceKey, &refKeySize);
|
||||
hr = file->GetReferenceKey(&referenceKey, &refKeySize);
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<IDWriteFontFileLoader> loader;
|
||||
file->GetLoader(getter_AddRefs(loader));
|
||||
hr = file->GetLoader(getter_AddRefs(loader));
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<IDWriteFontFileStream> stream;
|
||||
loader->CreateStreamFromKey(referenceKey, refKeySize, getter_AddRefs(stream));
|
||||
hr = loader->CreateStreamFromKey(referenceKey, refKeySize, getter_AddRefs(stream));
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT64 fileSize64;
|
||||
stream->GetFileSize(&fileSize64);
|
||||
if (fileSize64 > UINT32_MAX) {
|
||||
hr = stream->GetFileSize(&fileSize64);
|
||||
if (FAILED(hr) || fileSize64 > UINT32_MAX) {
|
||||
MOZ_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
@ -308,7 +320,10 @@ bool UnscaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback,
|
||||
uint32_t fileSize = static_cast<uint32_t>(fileSize64);
|
||||
const void* fragmentStart;
|
||||
void* context;
|
||||
stream->ReadFileFragment(&fragmentStart, 0, fileSize, &context);
|
||||
hr = stream->ReadFileFragment(&fragmentStart, 0, fileSize, &context);
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aDataCallback((uint8_t*)fragmentStart, fileSize, mFontFace->GetIndex(),
|
||||
aBaton);
|
||||
|
Loading…
x
Reference in New Issue
Block a user