From 0e36cf31618f63b1802cea342dd8fbbbe341bc6d Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Tue, 17 Mar 2026 11:37:00 +0000 Subject: [PATCH] [MPS] Protect Lisp_Objects in per-terminal coding systems * src/terminal.c (create_terminal): Create roots for the new 'safe_charsets_string' members, as well as 'src_object' and 'dst_object'. (delete_terminal_internal): Destroy them. --- src/terminal.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/terminal.c b/src/terminal.c index 5475a4092d2..1b15d1f26be 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -309,7 +309,13 @@ create_terminal (enum output_method type, struct redisplay_interface *rif) #ifdef HAVE_MPS terminal->keyboard_coding = xzalloc (sizeof (struct coding_system)); + igc_root_create_n (&terminal->keyboard_coding->src_object, 1); + igc_root_create_n (&terminal->keyboard_coding->dst_object, 1); + igc_root_create_n (&terminal->keyboard_coding->safe_charsets_string, 1); terminal->terminal_coding = xzalloc (sizeof (struct coding_system)); + igc_root_create_n (&terminal->terminal_coding->src_object, 1); + igc_root_create_n (&terminal->terminal_coding->dst_object, 1); + igc_root_create_n (&terminal->terminal_coding->safe_charsets_string, 1); #else terminal->keyboard_coding = xmalloc (sizeof (struct coding_system)); terminal->terminal_coding = xmalloc (sizeof (struct coding_system)); @@ -378,8 +384,19 @@ delete_terminal_internal (struct terminal *terminal) emacs_abort (); *tp = terminal->next_terminal; +#ifdef HAVE_MPS + igc_destroy_root_with_start (&terminal->keyboard_coding->src_object); + igc_destroy_root_with_start (&terminal->keyboard_coding->dst_object); + igc_destroy_root_with_start (&terminal->keyboard_coding->safe_charsets_string); +#endif xfree (terminal->keyboard_coding); terminal->keyboard_coding = NULL; + +#ifdef HAVE_MPS + igc_destroy_root_with_start (&terminal->terminal_coding->src_object); + igc_destroy_root_with_start (&terminal->terminal_coding->dst_object); + igc_destroy_root_with_start (&terminal->terminal_coding->safe_charsets_string); +#endif xfree (terminal->terminal_coding); terminal->terminal_coding = NULL;