From cee94df6e081b625a353bdd9a716cb8ef625e4cf Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 28 Sep 2009 09:36:40 -0300 Subject: [PATCH] function list in luaL_register may be NULL for an empty list --- lauxlib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lauxlib.c b/lauxlib.c index bdbe576c..ed82e8cd 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.190 2009/07/15 17:47:34 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.191 2009/09/18 18:58:45 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -672,7 +672,8 @@ LUALIB_API void luaL_register (lua_State *L, const char *libname, } lua_remove(L, -2); /* remove _LOADED table */ } - for (; l->name; l++) { + if (l == NULL) return; /* nothing to register? */ + for (; l->name; l++) { /* else fill the table with given functions */ lua_pushcfunction(L, l->func); lua_setfield(L, -2, l->name); }