Commit f2e0b70c authored by Jonathan Kew's avatar Jonathan Kew
Browse files

Bug 1686559 - Add null-checks for API calls that may be fallible. r=lsalzman, a=jcristau

Differential Revision:
parent 37a37bbd
......@@ -83,6 +83,9 @@ void NativeFontResourceMac::RegisterMemoryReporter() {
already_AddRefed<NativeFontResourceMac> NativeFontResourceMac::Create(
uint8_t* aFontData, uint32_t aDataLength) {
uint8_t* fontData = (uint8_t*)malloc(aDataLength);
if (!fontData) {
return nullptr;
memcpy(fontData, aFontData, aDataLength);
CFAllocatorContext context = {0, fontData, nullptr, nullptr,
nullptr, nullptr, nullptr, FontDataDeallocate,
......@@ -95,9 +98,17 @@ already_AddRefed<NativeFontResourceMac> NativeFontResourceMac::Create(
// we'll later release this CFDataRef.
CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, fontData,
aDataLength, allocator);
if (!data) {
return nullptr;
CTFontDescriptorRef ctFontDesc =
if (!ctFontDesc) {
return nullptr;
// creating the CGFontRef via the CTFont avoids the data being held alive
// in a cache.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment