Constrain brushx and brushy values (#716)

This commit is contained in:
QuanTech0 2020-05-09 13:54:12 -04:00 committed by GitHub
parent 9188f7bf8b
commit 49963980e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -445,9 +445,21 @@ int LuaScriptInterface::tpt_newIndex(lua_State *l)
luaL_error(l, "Invalid tool identifier: %s", lua_tostring(l, 3));
}
else if (!key.compare("brushx"))
c->SetBrushSize(ui::Point(luaL_checkinteger(l, 3), m->GetBrush()->GetRadius().Y));
{
int brushx = luaL_checkinteger(l, 3);
if (brushx < 0 || brushx >= XRES)
luaL_error(l, "Invalid brush width");
c->SetBrushSize(ui::Point(brushx, m->GetBrush()->GetRadius().Y));
}
else if (!key.compare("brushy"))
c->SetBrushSize(ui::Point(m->GetBrush()->GetRadius().X, luaL_checkinteger(l, 3)));
{
int brushy = luaL_checkinteger(l, 3);
if (brushy < 0 || brushy >= YRES)
luaL_error(l, "Invalid brush height");
c->SetBrushSize(ui::Point(m->GetBrush()->GetRadius().X, brushy));
}
else if (!key.compare("brushID"))
m->SetBrushID(luaL_checkinteger(l, 3));
else if (!key.compare("decoSpace"))