[coretext] Fix memory leaks.
In `reference_table`, if the data is empty and we return early, we still need to release the data object. In `hb_coretext_shape`, there two edge cases where an early return should release the attributed string.
This commit is contained in:
parent
f0b700db39
commit
0c66043a92
|
@ -74,7 +74,10 @@ reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data)
|
||||||
const char *data = reinterpret_cast<const char*> (CFDataGetBytePtr (cf_data));
|
const char *data = reinterpret_cast<const char*> (CFDataGetBytePtr (cf_data));
|
||||||
const size_t length = CFDataGetLength (cf_data);
|
const size_t length = CFDataGetLength (cf_data);
|
||||||
if (!data || !length)
|
if (!data || !length)
|
||||||
|
{
|
||||||
|
CFRelease (cf_data);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
return hb_blob_create (data, length, HB_MEMORY_MODE_READONLY,
|
return hb_blob_create (data, length, HB_MEMORY_MODE_READONLY,
|
||||||
reinterpret_cast<void *> (const_cast<__CFData *> (cf_data)),
|
reinterpret_cast<void *> (const_cast<__CFData *> (cf_data)),
|
||||||
|
@ -877,7 +880,10 @@ resize_and_retry:
|
||||||
kCFStringEncodingUTF8,
|
kCFStringEncodingUTF8,
|
||||||
kCFAllocatorNull);
|
kCFAllocatorNull);
|
||||||
if (unlikely (!lang))
|
if (unlikely (!lang))
|
||||||
|
{
|
||||||
|
CFRelease (attr_string);
|
||||||
FAIL ("CFStringCreateWithCStringNoCopy failed");
|
FAIL ("CFStringCreateWithCStringNoCopy failed");
|
||||||
|
}
|
||||||
CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len),
|
CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len),
|
||||||
kCTLanguageAttributeName, lang);
|
kCTLanguageAttributeName, lang);
|
||||||
CFRelease (lang);
|
CFRelease (lang);
|
||||||
|
@ -946,7 +952,10 @@ resize_and_retry:
|
||||||
&kCFTypeDictionaryValueCallBacks);
|
&kCFTypeDictionaryValueCallBacks);
|
||||||
CFRelease (level_number);
|
CFRelease (level_number);
|
||||||
if (unlikely (!options))
|
if (unlikely (!options))
|
||||||
|
{
|
||||||
|
CFRelease (attr_string);
|
||||||
FAIL ("CFDictionaryCreate failed");
|
FAIL ("CFDictionaryCreate failed");
|
||||||
|
}
|
||||||
|
|
||||||
CTTypesetterRef typesetter = CTTypesetterCreateWithAttributedStringAndOptions (attr_string, options);
|
CTTypesetterRef typesetter = CTTypesetterCreateWithAttributedStringAndOptions (attr_string, options);
|
||||||
CFRelease (options);
|
CFRelease (options);
|
||||||
|
|
Loading…
Reference in New Issue