mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Simple decorations: Fix range check for deco->deco_param2
Allow any int value, and properly range check it before casting.
This commit is contained in:
parent
24719c6908
commit
5a2431a9bd
@ -972,10 +972,10 @@ int ModApiMapgen::l_register_decoration(lua_State *L)
|
|||||||
bool read_deco_simple(lua_State *L, DecoSimple *deco)
|
bool read_deco_simple(lua_State *L, DecoSimple *deco)
|
||||||
{
|
{
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
int param2;
|
||||||
|
|
||||||
deco->deco_height = getintfield_default(L, index, "height", 1);
|
deco->deco_height = getintfield_default(L, index, "height", 1);
|
||||||
deco->deco_height_max = getintfield_default(L, index, "height_max", 0);
|
deco->deco_height_max = getintfield_default(L, index, "height_max", 0);
|
||||||
deco->deco_param2 = getintfield_default(L, index, "param2", 0);
|
|
||||||
|
|
||||||
if (deco->deco_height <= 0) {
|
if (deco->deco_height <= 0) {
|
||||||
errorstream << "register_decoration: simple decoration height"
|
errorstream << "register_decoration: simple decoration height"
|
||||||
@ -991,11 +991,13 @@ bool read_deco_simple(lua_State *L, DecoSimple *deco)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((deco->deco_param2 < 0) || (deco->deco_param2 > 255)) {
|
param2 = getintfield_default(L, index, "param2", 0);
|
||||||
|
if ((param2 < 0) || (param2 > 255)) {
|
||||||
errorstream << "register_decoration: param2 out of bounds (0-255)"
|
errorstream << "register_decoration: param2 out of bounds (0-255)"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
deco->deco_param2 = (u8)param2;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user