From ba9f2a5148ce9142137fd96eb78d78c84e233a20 Mon Sep 17 00:00:00 2001
From: Max Chernoff <49086429+gucci-on-fleek@users.noreply.github.com>
Date: Tue, 4 Jul 2023 23:50:38 -0600
Subject: [PATCH 2/3] Guard against too-large t3 character indices

---
 source/texk/web2c/luatexdir/font/luafont.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/source/texk/web2c/luatexdir/font/luafont.c b/source/texk/web2c/luatexdir/font/luafont.c
index c3303724..38c98541 100644
--- a/source/texk/web2c/luatexdir/font/luafont.c
+++ b/source/texk/web2c/luatexdir/font/luafont.c
@@ -1352,6 +1352,16 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int
     int nk = 0;
     int ctr = 0;
     int atsize = font_size(f);
+
+    if (i > 256 &&
+        font_encodingbytes(f) != 2 &&
+        font_psname(f) != NULL &&
+        strstr(font_psname(f),"none")
+    ) {
+        formatted_warning("font", "lua-loaded font %s index %X is too large for Type 3", font_name(f), (int) i);
+        return;
+    }
+
     if (lua_istable(L, -1)) {
         co = get_charinfo(f, i);
         set_charinfo_tag(co, 0);
-- 
2.41.0

