lua-users home
lua-l archive

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

Dear Lunatics,

I seek your advice.
I am running Lua 5.2 RC5 compiled with C++ Builder XE2.

When using luaL_checklstring() over a nil value on the Lua stack,
a system exception is raised.

The minimal snippet that reproduces the problem is below:

extern "C" {
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"

void __fastcall TForm6::Button1Click(TObject *Sender)
 lua_State* L = luaL_newstate();
 if (L) {
   bool isnil = lua_isnil(L, -1);
   unsigned int size;
   try {
     const char* p = luaL_checklstring(L, -1, &size);
   catch (...) {

I expected that the function luaL_checklstring() would return NULL, instead of raising an exception.
The questions is:

 ( )  I misundestood how to use luaL_checklstring, and it is not safe to do it over a nil value.
 ( ) This issue is C++ [Builder] specific and it does not manifest in other platforms
 ( ) There is a bug in luaL_checklstring

I would appreciate your advice if my code and expectations are wrong.
Otherwise, if this is indeed a bug, I can reproduce and further explore the problem in my platform
provided a more experienced in Lua partner give me guidance about what to change inside Lua source code.

best regards,
Rod Senra