To quote from the reference manual :
> luaL_newstate [-0, +0, –]
> Returns the new state, or NULL if there is a memory allocation error.
But now luaL_openlibs will call lua_newuserdatauv and luaL_ref, and then they have a chance to raise a memory error.