Lua_tostring weirdness

  • From: rob <rob.mail@xxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 07 Aug 2012 13:20:59 +0200


Using Lua, lua_tostring returns string pointers and a null pointer if the given index in the stack does not exist, e.g. -1 when a registered C function passes no arguments from Lua.

However, as I have found out the hard way, LuaJit seems to always return a valid pointer, thus now even without passed arguments I have things like '1.2282043745381e-306', resulting in a memory access error in my function.

Is there a way to check if a given stack index is empty, i.e. there is no passed value, or have a null pointer returned?


Other related posts: