aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-07-22 13:48:43 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-07-22 13:48:43 -0300
commit439e45a2f69549b674d6a6e2023e8debfa00a2b8 (patch)
tree416db940cc3e4826119fda14d47f579b60cfb99b /ltests.c
parent62fb93442753cbfb828335cd172e71471dffd536 (diff)
downloadlua-439e45a2f69549b674d6a6e2023e8debfa00a2b8.tar.gz
lua-439e45a2f69549b674d6a6e2023e8debfa00a2b8.tar.bz2
lua-439e45a2f69549b674d6a6e2023e8debfa00a2b8.zip
Bug: luaL_tolstring may get confused with negative index
When object has a '__name' metafield, 'luaL_tolstring' used the received index after pushing a string on the stack.
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ltests.c b/ltests.c
index a50f7830..97834e38 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1743,6 +1743,9 @@ static struct X { int x; } x;
1743 (void)s1; /* to avoid warnings */ 1743 (void)s1; /* to avoid warnings */
1744 lua_longassert((s == NULL && s1 == NULL) || strcmp(s, s1) == 0); 1744 lua_longassert((s == NULL && s1 == NULL) || strcmp(s, s1) == 0);
1745 } 1745 }
1746 else if EQ("Ltolstring") {
1747 luaL_tolstring(L1, getindex, NULL);
1748 }
1746 else if EQ("type") { 1749 else if EQ("type") {
1747 lua_pushstring(L1, luaL_typename(L1, getnum)); 1750 lua_pushstring(L1, luaL_typename(L1, getnum));
1748 } 1751 }