From b9d7be372f214f70edcacb14520eddbb5836d9e8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 24 Aug 2019 03:35:23 +0200 Subject: [PATCH] (CoreText) Check first if path is valid --- gfx/drivers_font_renderer/coretext.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gfx/drivers_font_renderer/coretext.c b/gfx/drivers_font_renderer/coretext.c index 33a321b97e..93efb1ae2e 100644 --- a/gfx/drivers_font_renderer/coretext.c +++ b/gfx/drivers_font_renderer/coretext.c @@ -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) {