diff options
| author | Eli Zaretskii | 2025-03-23 13:17:06 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2025-03-23 13:17:06 +0200 |
| commit | 939a2a3c2dd60503c6ebef839b5f05f962d405ce (patch) | |
| tree | af2fac37e98d0861dc81466f10d6be563c71a385 | |
| parent | 467aba67db407e930fc5de6d4a4ae0cd6fc106df (diff) | |
| download | emacs-939a2a3c2dd60503c6ebef839b5f05f962d405ce.tar.gz emacs-939a2a3c2dd60503c6ebef839b5f05f962d405ce.zip | |
Avoid rare crashes due to "C-g C-g" on TTY frames
* src/term.c (tty_send_additional_strings): Don't use SBYTES, as
this function could be called in the middle of GC. (Bug#77205)
| -rw-r--r-- | src/term.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/term.c b/src/term.c index e15b7a0887e..32f3c8c48d6 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -184,9 +184,15 @@ tty_send_additional_strings (struct terminal *terminal, Lisp_Object sym) | |||
| 184 | Lisp_Object string = XCAR (extra_codes); | 184 | Lisp_Object string = XCAR (extra_codes); |
| 185 | if (STRINGP (string)) | 185 | if (STRINGP (string)) |
| 186 | { | 186 | { |
| 187 | fwrite (SDATA (string), 1, SBYTES (string), tty->output); | 187 | struct Lisp_String *str = XSTRING (string); |
| 188 | /* Don't use SBYTES, as that is not protected from GC. */ | ||
| 189 | ptrdiff_t sbytes | ||
| 190 | = (str->u.s.size_byte < 0 | ||
| 191 | ? str->u.s.size & ~ARRAY_MARK_FLAG | ||
| 192 | : str->u.s.size_byte); | ||
| 193 | fwrite (SDATA (string), 1, sbytes, tty->output); | ||
| 188 | if (tty->termscript) | 194 | if (tty->termscript) |
| 189 | fwrite (SDATA (string), 1, SBYTES (string), tty->termscript); | 195 | fwrite (SDATA (string), 1, sbytes, tty->termscript); |
| 190 | } | 196 | } |
| 191 | } | 197 | } |
| 192 | } | 198 | } |