From 55d1ea5cf05a3acb22890cd63dca446dd8e9f8d9 Mon Sep 17 00:00:00 2001 From: Jehan Date: Mon, 30 Apr 2018 22:02:31 +0200 Subject: [PATCH] app: check that the font path is not NULL. This is for Windows where we apparently need to call g_win32_locale_filename_from_utf8() before feeding the path to FcConfigAppFontAddFile(). Unfortunately as we discovered earlier (cf. commit ba06a0fe86), this can sometimes return NULL. So we absolutely need to check for the path not being NULL first. --- app/text/gimp-fonts.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/text/gimp-fonts.c b/app/text/gimp-fonts.c index 3660602251..d708d871d9 100644 --- a/app/text/gimp-fonts.c +++ b/app/text/gimp-fonts.c @@ -307,10 +307,15 @@ gimp_fonts_recursive_add_fontdir (FcConfig *config, gchar *tmp = g_win32_locale_filename_from_utf8 (path); g_free (path); + /* XXX: g_win32_locale_filename_from_utf8() may return + * NULL. So we need to check that path is not NULL before + * trying to load with fontconfig. + */ path = tmp; #endif - if (FcFalse == FcConfigAppFontAddFile (config, (const FcChar8 *) path)) + if (! path || + FcFalse == FcConfigAppFontAddFile (config, (const FcChar8 *) path)) { g_printerr ("%s: adding font file '%s' failed.\n", G_STRFUNC, path);