c++ - Safely reading string from Lua stack -
How is it possible to read string values safely from Lua Stack? Both the function lua_tostring and lua_tolstring can both increase a Lua error (longjmp / exception of a strange type). Therefore the function should probably be called in protected mode using lua_pcall , but I can not find a good solution how to do this and get string value from Lava stack to C ++. Really need to call lua_tolstring in safe mode using lua_pcall ? In fact it is bad to use lua_pcall because the string I want to read from the Lua Stack is an error message stored by lua_pcall . lua_tostring before lua_type : If lua_type returns LUA_TSTRING , then you will not be allocated any more memory to get the lua_tostring string securely. lua_tostring allocates only memory when it has to convert a number to a string.
Comments
Post a Comment