Fix leak and possible segfault in minetest.set_mapgen_params

This commit is contained in:
kwolekr 2013-12-08 01:37:41 -05:00
parent 83cc882335
commit 3cc45fd8ad
1 changed files with 42 additions and 40 deletions

View File

@ -167,7 +167,7 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L)
return 0;
EmergeManager *emerge = getServer(L)->getEmergeManager();
if (emerge->mapgen.size())
if (!emerge || emerge->mapgen.size())
return 0;
MapgenParams *oparams = new MapgenParams;
@ -205,6 +205,8 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L)
}
}
delete emerge->luaoverride_params;
emerge->luaoverride_params = oparams;
emerge->luaoverride_params_modified = paramsmodified;
emerge->luaoverride_flagmask = flagmask;