Hi,
In fact, at the moment, I don't know if it is a true issue (tell me).
In plugin_lua.c, the luaLoadFile function is as follows:
/* Load 'file' */
static int luaLoadFile_old(lua_State *L, const char *file)
{
const char *path = hooks->create_mapdir_pathname(file);
int res = 0;
if ((res = luaFindFile(L, file, &path)) == 0)
{
if ((res = load_file_cache(L, path)) == 0)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, cache_ref);
lua_pushstring(L, file);
lua_rawget(L, -2);
if (!lua_isfunction(L, -1))
{
lua_pop(L, 1);
lua_pushstring(L, file);
lua_pushstring(L, path);
lua_rawset(L, -3);
}
lua_pop(L, 1);
}
}
return res;
}
The expected behaviour of this function is to put at the top of the lua stack the lua function loaded (or an error message).
If !lua_isfunction(L, -1) returns false (for the moment, I don't how it can occur), the stack will contain the cache table (at the top) and the lua function. From my point of view, the cache table should be removed from the top of the stack.
I would suggest the following correction:
/* Load 'file' */
static int luaLoadFile(lua_State *L, const char *file)
{
const char *path = hooks->create_mapdir_pathname(file);
int res = 0;
if ((res = luaFindFile(L, file, &path)) == 0)
{
if ((res = load_file_cache(L, path)) == 0)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, cache_ref);
lua_pushstring(L, file);
lua_pushstring(L, path);
lua_rawset(L, -3);
lua_pop(L, 1);
}
}
return res;
}