From 2f128c5130b962bc691aa1f7eaf5882b3e826c23 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 19 Apr 2011 15:29:41 -0300 Subject: [PATCH] 'luaL_setfuncs' does not need to accept a NULL list. (If there is no list, there is no reason to call this function.) --- lauxlib.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lauxlib.c b/lauxlib.c index bcd4fa1d..3332b2ca 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.229 2011/03/03 16:34:46 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.230 2011/04/08 19:17:36 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -825,7 +825,10 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */ lua_insert(L, -(nup + 1)); /* move library table to below upvalues */ } - luaL_setfuncs(L, l, nup); + if (l) + luaL_setfuncs(L, l, nup); + else + lua_pop(L, nup); /* remove upvalues */ } #endif @@ -838,7 +841,7 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, */ LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { luaL_checkstack(L, nup, "too many upvalues"); - for (; l && l->name; l++) { /* fill the table with given functions */ + for (; l->name != NULL; l++) { /* fill the table with given functions */ int i; for (i = 0; i < nup; i++) /* copy upvalues to the top */ lua_pushvalue(L, -nup);