From b0e49d70db224c13d99957d97aca503c0a9f3dd1 Mon Sep 17 00:00:00 2001 From: Matubu Date: Fri, 18 Oct 2024 02:24:47 +0200 Subject: [PATCH] Fix segfault when font descriptor point to invalid font file --- kitty/fontconfig.c | 2 +- kitty/freetype.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kitty/fontconfig.c b/kitty/fontconfig.c index 224cb5f433..bfc081ca75 100644 --- a/kitty/fontconfig.c +++ b/kitty/fontconfig.c @@ -520,7 +520,7 @@ create_fallback_face(PyObject UNUSED *base_face, CPUCell* cell, bool bold, bool } } ans = face_from_descriptor(d, fg); - if (!glyph_found) glyph_found = has_cell_text(face_has_codepoint, ans, cell, false); + if (!glyph_found && ans) glyph_found = has_cell_text(face_has_codepoint, ans, cell, false); } end: Py_CLEAR(d); diff --git a/kitty/freetype.c b/kitty/freetype.c index d28ffee0e2..ff6ace5468 100644 --- a/kitty/freetype.c +++ b/kitty/freetype.c @@ -279,7 +279,7 @@ face_from_descriptor(PyObject *descriptor, FONTS_DATA_HANDLE fg) { if (retval != NULL) { Face *self = (Face *)retval; int error; - if ((error = FT_New_Face(library, path, index, &(self->face)))) { self->face = NULL; set_load_error(path, error); } + if ((error = FT_New_Face(library, path, index, &(self->face)))) { self->face = NULL; return set_load_error(path, error); } if (!init_ft_face(self, PyDict_GetItemString(descriptor, "path"), hinting, hint_style, fg)) return NULL; PyObject *ns = PyDict_GetItemString(descriptor, "named_style"); if (ns) {