From 834160d1cd038ceb5fdb8cba7355a17d4dc7c7ff Mon Sep 17 00:00:00 2001 From: MCJack123 Date: Sun, 9 Jul 2023 04:54:10 -0400 Subject: [PATCH] Fixed stack corruption when using `string.format("%q")` --- src/lstrlib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lstrlib.c b/src/lstrlib.c index f90c321..0087134 100644 --- a/src/lstrlib.c +++ b/src/lstrlib.c @@ -756,9 +756,10 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { case LUA_TNUMBER: s = luaL_tolstring(L, arg, &l); /* pushes the string version to the top of the stack */ luaL_addlstring(b, s, l); + lua_pop(L, 1); break; case LUA_TSTRING: { - s = luaL_tolstring(L, arg, &l); + s = lua_tolstring(L, arg, &l); luaL_addchar(b, '"'); while (l--) { switch (*s) {