From 8e51a3e3f8fc6dcb7b195bf57722a72a281552e8 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 22 Aug 2023 17:34:41 +0800 Subject: [PATCH] Avoid crashes rescaling fonts with long names * src/font.c (font_rescale_ratio): Check NAME is not nil before matching it against a regexp. --- src/font.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/font.c b/src/font.c index 7f8ddc4dc34..ff81fefcad0 100644 --- a/src/font.c +++ b/src/font.c @@ -1879,7 +1879,11 @@ font_rescale_ratio (Lisp_Object font_entity) { if (NILP (name)) name = Ffont_xlfd_name (font_entity, Qnil); - if (fast_string_match_ignore_case (XCAR (elt), name) >= 0) + + /* N.B. that `name' is set to nil if the resulting XLFD + is too long. */ + if (!NILP (name) + && fast_string_match_ignore_case (XCAR (elt), name) >= 0) return XFLOAT_DATA (XCDR (elt)); } else if (FONT_SPEC_P (XCAR (elt))) -- 2.39.2