Skip to content

Commit

Permalink
Fix potential crash when using an [engine]name=lua
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel authored and mattsc committed Mar 22, 2016
1 parent ad075af commit a5d131c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ai/lua/core.cpp
Expand Up @@ -84,6 +84,14 @@ void lua_ai_context::set_persistent_data(const config &cfg)
lua_pushlightuserdata(L, static_cast<void *>(const_cast<char *>(&aisKey)));
lua_rawget(L, LUA_REGISTRYINDEX);
lua_rawgeti(L, -1, num_);

if(lua_isnoneornil(L, -1)) {
// Just in case the self table wasn't initialized.
lua_pop(L, 1);
lua_newtable(L);
lua_rawseti(L, -2, num_);
lua_rawgeti(L, -1, num_);
}

luaW_pushconfig(L, cfg);
lua_setfield(L, -2, "data");
Expand Down

0 comments on commit a5d131c

Please sign in to comment.