mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 08:42:59 +00:00
[coretext] Handle allocation failures
This commit is contained in:
parent
8c561733b6
commit
1bc87dfed2
1 changed files with 9 additions and 2 deletions
|
@ -523,13 +523,19 @@ hb_coretext_font_create (CTFontRef ct_font)
|
|||
CFDictionaryRef variations = CTFontCopyVariation (ct_font);
|
||||
if (variations)
|
||||
{
|
||||
hb_vector_t<hb_variation_t> vars;
|
||||
|
||||
CFIndex count = CFDictionaryGetCount (variations);
|
||||
// Fetch them one by one and collect in a vector of our own.
|
||||
CFTypeRef *keys = (CFTypeRef*) hb_malloc (sizeof (CFTypeRef) * count);
|
||||
CFTypeRef *values = (CFTypeRef*) hb_malloc (sizeof (CFTypeRef) * count);
|
||||
CFDictionaryGetKeysAndValues (variations, keys, values);
|
||||
if (unlikely (!keys || !values))
|
||||
goto done;
|
||||
|
||||
hb_vector_t<hb_variation_t> vars;
|
||||
if (unlikely (!vars.alloc (count)))
|
||||
goto done;
|
||||
|
||||
CFDictionaryGetKeysAndValues (variations, keys, values);
|
||||
for (CFIndex i = 0; i < count; i++)
|
||||
{
|
||||
int tag;
|
||||
|
@ -542,6 +548,7 @@ hb_coretext_font_create (CTFontRef ct_font)
|
|||
}
|
||||
hb_font_set_variations (font, vars.arrayZ, vars.length);
|
||||
|
||||
done:
|
||||
hb_free (keys);
|
||||
hb_free (values);
|
||||
CFRelease (variations);
|
||||
|
|
Loading…
Add table
Reference in a new issue