From 98bd0d16fe72d1d2b6d6cd94cb8cd77d0fbc895e Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 16 Dec 2025 15:22:16 +0100 Subject: [PATCH] Issue #15501: g_close failed with EBADF. This is not a valid file descriptor. I can't reproduce this issue, because when I set a fake font file as a broken symlink, or a file without read access, it is simply not returned as part of my font list to start with. But from the issue discussion and traces, this should be the right fix. --- app/text/gimpfontfactory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/text/gimpfontfactory.c b/app/text/gimpfontfactory.c index ae24eaf7a4..36e8f01c23 100644 --- a/app/text/gimpfontfactory.c +++ b/app/text/gimpfontfactory.c @@ -860,7 +860,16 @@ gimp_font_factory_load_names (GimpFontFactory *factory) */ { char buf[4] = {0}; - int fd = g_open ((gchar *) file, O_RDONLY, 0); + int fd; + + errno = 0; + fd = g_open ((gchar *) file, O_RDONLY, 0); + if (fd == -1) + { + g_string_append_printf (ignored_fonts, "- %s (access error: %s)\n", file, strerror (errno)); + n_ignored++; + continue; + } read (fd, buf, 4); g_close (fd, NULL);