Fix leak and possible segfault in minetest.set_mapgen_params
parent
83cc882335
commit
3cc45fd8ad
|
@ -167,7 +167,7 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
EmergeManager *emerge = getServer(L)->getEmergeManager();
|
EmergeManager *emerge = getServer(L)->getEmergeManager();
|
||||||
if (emerge->mapgen.size())
|
if (!emerge || emerge->mapgen.size())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
MapgenParams *oparams = new MapgenParams;
|
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 = oparams;
|
||||||
emerge->luaoverride_params_modified = paramsmodified;
|
emerge->luaoverride_params_modified = paramsmodified;
|
||||||
emerge->luaoverride_flagmask = flagmask;
|
emerge->luaoverride_flagmask = flagmask;
|
||||||
|
|
Loading…
Reference in New Issue