On Mon, Oct 22, 2018 at 9:58 PM Marcel Krüger <tex@2krueger.de> wrote:
Hi,

in the implementation of \letcharcode LuaTeX calls `set_token_info(cur_cs, cur_cs + cs_token_flag);`.
This is weird, because the first argument to `set_token_info` is supposed to be a pointer to a one-word node  as returned by `get_avail` and not a `cs`.

I've got a document where this caused LuaTeX to overwrite a random token in a different macro every time `\letcharcode` was called.
The active token isn't stored anywhere, so this can be fixed by just omitting `set_token_info`.


Best regards
Marcel Krüger



Suggested patch:

diff --git a/source/texk/web2c/luatexdir/tex/maincontrol.c b/source/texk/web2c/luatexdir/tex/maincontrol.c
index 05e385b27..25acf1ea9 100644
--- a/source/texk/web2c/luatexdir/tex/maincontrol.c
+++ b/source/texk/web2c/luatexdir/tex/maincontrol.c
@@ -2698,9 +2698,7 @@ void prefixed_command(void)
                     /*tex |letcharcode| */
                     scan_int();
                     if (cur_val > 0) {
-                        cur_cs = active_to_cs(cur_val, true);
-                        set_token_info(cur_cs, cur_cs + cs_token_flag);
-                        p = cur_cs;
+                        p = active_to_cs(cur_val, true);
                         do {
                             get_token();
                         } while (cur_cmd == spacer_cmd);

_______________________________________________
dev-luatex mailing list
dev-luatex@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-luatex

Thank you for the report. 
Do you have a sample document ?

--
luigi