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.
This commit is contained in:
Jehan 2025-12-16 15:22:16 +01:00
parent 75fd88e881
commit 98bd0d16fe

View file

@ -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);