From 89db933a2401d50fafef492376ea654a94b28eb6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 24 Oct 2026 06:28:36 +0530 Subject: [PATCH] Fix #10729 --- docs/changelog.rst | 3 +++ kitty/fonts.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index b64f2557f..2a6b7f49b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -450,6 +450,9 @@ Detailed list of changes or too thick when zoomed out. At the configured :opt:`font_size` nothing changes (:iss:`10362`) +- Fix a use-after-free that could cause a crash when reloading the config after + changing font settings (:iss:`10729`) + 0.49.2 [2026-10-01] diff --git a/kitty/fonts.c b/kitty/fonts.c index c1a1a28d6..f9faf1202 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -573,6 +573,9 @@ init_font(Font *f, PyObject *face, bool bold, bool italic, bool emoji_presentati static void free_font_groups(void) { if (font_groups) { + // Clear dangling pointers into font_groups, otherwise the next call to + // save_window_font_groups() would read freed memory + for (size_t o = 0; o < global_state.num_os_windows; o++) global_state.os_windows[o].fonts_data = NULL; for (size_t i = 0; i < num_font_groups; i++) del_font_group(font_groups + i); free(font_groups); font_groups = NULL;