FLTK logo

[master] 2a5c232 - Fix for issue #454 : crash in Fl::get_font_name().

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 2a5c232 - Fix for issue #454 : crash in Fl::get_font_name(). "ManoloFLTK" Jun 27, 2022  
 
commit 2a5c2322f195b0db1fbe2e67df3d91ff77ace6fe
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Jun 27 13:25:35 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Jun 27 13:25:35 2022 +0200

    Fix for issue #454 : crash in Fl::get_font_name().

 src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
index ce2a7e2..e3b03b9 100644
--- src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
+++ src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
@@ -318,13 +318,16 @@ double Fl_Quartz_Graphics_Driver::width(unsigned int wc) {
 static void set_fontname_CoreText(Fl_Fontdesc *f) {
   CFStringRef cfname = CFStringCreateWithCString(NULL, f->name, kCFStringEncodingUTF8);
   CTFontRef ctfont = cfname ? CTFontCreateWithName(cfname, 0, NULL) : NULL;
-  if (cfname) CFRelease(cfname);
+  if (cfname) { CFRelease(cfname); cfname = NULL; }
   if (ctfont) {
     cfname = CTFontCopyFullName(ctfont);
     CFRelease(ctfont);
-    CFStringGetCString(cfname, f->fontname, ENDOFBUFFER, kCFStringEncodingUTF8);
-    CFRelease(cfname);
-  } else strlcpy(f->fontname, f->name, ENDOFBUFFER);
+    if (cfname) {
+      CFStringGetCString(cfname, f->fontname, ENDOFBUFFER, kCFStringEncodingUTF8);
+      CFRelease(cfname);
+    }
+  }
+  if (!cfname) strlcpy(f->fontname, f->name, ENDOFBUFFER);
 }
 #endif
 
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.