From 68587639945aa68844871fdd74a6729b653f523a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 1 Feb 2001 11:56:49 -0200 Subject: [PATCH] bug in lua_pushuserdata(L, NULL) --- bugs | 5 +++++ lapi.c | 3 ++- lstring.c | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bugs b/bugs index a1391524..220a36bf 100644 --- a/bugs +++ b/bugs @@ -250,3 +250,8 @@ Fri Dec 22 15:30:42 EDT 2000 >> when `read' fails it must return nil (and not no value) (by cassino; since at least 3.1) +** lstring.c/lapi.c +Thu Feb 1 11:55:45 EDT 2001 +>> lua_pushuserdata(L, NULL) is buggy +(by Edgar Toernig; since 4.0) + diff --git a/lapi.c b/lapi.c index 614d237e..bf66e3e9 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 1.121 2001/01/26 11:45:51 roberto Exp roberto $ +** $Id: lapi.c,v 1.122 2001/01/29 17:16:58 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -702,6 +702,7 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) { TString *ts; void *p; LUA_LOCK; + if (size == 0) size = 1; ts = luaS_newudata(L, size, NULL); setuvalue(L->top, ts); api_incr_top(L); diff --git a/lstring.c b/lstring.c index ee087e9b..fbc56dd0 100644 --- a/lstring.c +++ b/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 1.52 2001/01/26 15:58:50 roberto Exp roberto $ +** $Id: lstring.c,v 1.53 2001/01/29 19:34:02 roberto Exp roberto $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -97,7 +97,7 @@ TString *luaS_newudata (lua_State *L, size_t s, void *udata) { ts->nexthash = NULL; ts->len = s; ts->u.d.tag = 0; - ts->u.d.value = (udata == NULL) ? uts+1 : udata; + ts->u.d.value = (s > 0) ? uts+1 : udata; /* insert it on table */ newentry(L, &G(L)->udt, ts, lmod(IntPoint(ts->u.d.value), G(L)->udt.size)); return ts;