lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Using a negtive index in luaL_tolstring can result in wrong results.
This happens in where the negative index will be used in the lua_topointer call, however, a value was pushed before which changes the value the negative index points to. This can be happen in and the following output shows the problem:

Lua 5.4.4  Copyright (C) 1994-2021, PUC-Rio
> debug.debug()
lua_debug> x = {}
lua_debug> print(x)
table: 0x55627dc57140
lua_debug> error(setmetatable(x,{__name="N"}))
N: 0x55627dc57870
lua_debug> print(string.format("%p",getmetatable(x).__name))

The output N: 0x55627dc57870 prints the pointer of the string "N" instead of the pointer of the table.