(CoreText) Check first if path is valid

This commit is contained in:
twinaphex 2019-08-24 03:35:23 +02:00
parent 8d9812985b
commit b9d7be372f

View File

@ -262,13 +262,14 @@ static void *font_renderer_ct_init(const char *font_path, float font_size)
ct_font_renderer_t *handle = (ct_font_renderer_t*)
calloc(1, sizeof(*handle));
if (!handle)
if (!handle || !string_is_valid(font_path))
{
err = 1;
goto error;
}
cf_font_path = CFStringCreateWithCString(NULL, font_path, kCFStringEncodingASCII);
cf_font_path = CFStringCreateWithCString(
NULL, font_path, kCFStringEncodingASCII);
if (!cf_font_path)
{
@ -276,10 +277,11 @@ static void *font_renderer_ct_init(const char *font_path, float font_size)
goto error;
}
url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cf_font_path, kCFURLPOSIXPathStyle, false);
url = CFURLCreateWithFileSystemPath(
kCFAllocatorDefault, cf_font_path, kCFURLPOSIXPathStyle, false);
dataProvider = CGDataProviderCreateWithURL(url);
theCGFont = CGFontCreateWithDataProvider(dataProvider);
face = CTFontCreateWithGraphicsFont(theCGFont, font_size, NULL, NULL);
theCGFont = CGFontCreateWithDataProvider(dataProvider);
face = CTFontCreateWithGraphicsFont(theCGFont, font_size, NULL, NULL);
if (!face)
{