1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 12:21:25 -08:00

Check for end-of-file when reading character escapes (bug#79097)

* src/lread.c (read_char_escape): Add check.
* test/src/lread-tests.el (lread-char-escape-eof): New test.
This commit is contained in:
Mattias Engdegård 2025-07-25 21:53:37 +02:00
parent 50ffb29d0b
commit 33161e51e5
2 changed files with 33 additions and 0 deletions

View file

@ -3108,6 +3108,8 @@ read_char_escape (source_t *source, int next_char)
chr = c;
break;
}
if (chr < 0)
end_of_file_error ();
eassert (chr >= 0 && chr < (1 << CHARACTERBITS));
/* Apply Control modifiers, using the rules:

View file

@ -358,6 +358,37 @@ literals (Bug#20852)."
(should-error (read-from-string "?\\\n x"))
(should (equal (read-from-string "\"a\\\nb\"") '("ab" . 6))))
(ert-deftest lread-char-escape-eof ()
;; Check that unfinished char escapes signal an error.
(should-error (read "?\\"))
(should-error (read "?\\^"))
(should-error (read "?\\C"))
(should-error (read "?\\M"))
(should-error (read "?\\S"))
(should-error (read "?\\H"))
(should-error (read "?\\A"))
(should-error (read "?\\C-"))
(should-error (read "?\\M-"))
(should-error (read "?\\S-"))
(should-error (read "?\\H-"))
(should-error (read "?\\A-"))
(should-error (read "?\\s-"))
(should-error (read "?\\C-\\"))
(should-error (read "?\\C-\\M"))
(should-error (read "?\\C-\\M-"))
(should-error (read "?\\x"))
(should-error (read "?\\u"))
(should-error (read "?\\u234"))
(should-error (read "?\\U"))
(should-error (read "?\\U0010010"))
(should-error (read "?\\N"))
(should-error (read "?\\N{"))
(should-error (read "?\\N{SPACE")))
(ert-deftest lread-force-load-doc-strings ()
;; Verify that lazy doc strings are loaded lazily by default,
;; but eagerly with `force-load-doc-strings' set.