lua-users home
lua-l archive

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


On Wed, May 29, 2002 at 12:10:13PM +0200, Nutritious Games - Tue Hald Madsen wrote:
> I have a little problem.  When I use tolua, i get a debug error when
> trying to call the tolua_myclass_open() function from inside a
> member function of my class.  I have compiled the tolua library into
> a lib file, wich also contains lua 4.0.  I use the tolua 4.0a.
> Am I calling the wrong function at a wrong time ?

a "debug error" is not very specific, so I can't even guess what is
going on.

However, as a shot in the dark, tolua contains a rather nasty bug that
corrupts the heap. Try applying the following patch - even if it does
not solve your specific problem, it fixes a different one that might
bite you later.

--- snip ---
RCS file: /home3/cvogler/src/cvs/3rdParty/tolua/src/lib/tolua_gp.c,v
retrieving revision
retrieving revision
diff -u -r1. -r1.
--- src/lib/tolua_gp.c  2001/03/06 03:50:09
+++ src/lib/tolua_gp.c  2001/03/11 23:43:29
@@ -40,7 +40,13 @@

 int tolua_getvalue (lua_State* L, int narg, int def)
- return lua_gettop(L)<abs(narg) ? def : narg;
+ if (lua_gettop(L)<abs(narg))
+ {
+  lua_pushnil(L);
+  return lua_gettop(L);
+ }
+ else
+  return narg;

 int tolua_getbool (lua_State* L, int narg, int def)
--- snip ---

- Christian