From 5252c45850b3c4a3914f6c94dc163c2c23286bbf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org> Date: Sun, 19 Sep 2021 16:16:34 +0200 Subject: [PATCH] Initialise unread buffer The reader has an extra 1-char unread buffer that was incorrectly initialised to 0, which means that the first character read would always be NUL. As this is often the code that looks for the lexical-binding cookie, the first loaded source module would be treated as dynamically bound. During bootstrapping this is loadup.el and so its local variables got dumped into the global environment. * src/lread.c (unread_char): Initialise to empty. (Fload): Initialise here too just in case. --- src/lread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lread.c b/src/lread.c index a6c2db5d994..2abe2fd91ab 100644 --- a/src/lread.c +++ b/src/lread.c @@ -192,7 +192,7 @@ static int readbyte_from_string (int, Lisp_Object); Qlambda, or a cons, we use this to keep an unread character because a file stream can't handle multibyte-char unreading. The value -1 means that there's no unread character. */ -static int unread_char; +static int unread_char = -1; static int readchar (Lisp_Object readcharfun, bool *multibyte) @@ -1507,6 +1507,7 @@ Return t if the file exists and loads successfully. */) input.stream = stream; input.lookahead = 0; infile = &input; + unread_char = -1; } if (! NILP (Vpurify_flag)) -- 2.39.5