Fix crash with bad `parts[next]` index

develop
kaetemi 4 years ago
parent a227dccbb8
commit 8a7e96f7a6
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -1039,36 +1039,39 @@ namespace NLGUI
// second loop -> false && break
loop = !loop;
val = toLowerAscii(parts[next]);
if (val == "center")
{
if (bgPositionX.empty()) bgPositionX = "center";
if (bgPositionY.empty()) bgPositionY = "center";
// consume 'center'
next++;
}
else if (val == "left" || val == "right")
if (next < parts.size())
{
bgPositionX = val;
// consume 'left|right'
next++;
if(next < parts.size() && getCssLength(fval, unit, parts[next]))
val = toLowerAscii(parts[next]);
if (val == "center")
{
bgPositionX += " " + toString("%.0f%s", fval, unit.c_str());
// consume css length
if (bgPositionX.empty()) bgPositionX = "center";
if (bgPositionY.empty()) bgPositionY = "center";
// consume 'center'
next++;
}
}
else if (val == "top" || val == "bottom")
{
bgPositionY = val;
// consume top|bottom
next++;
if (next < parts.size() && getCssLength(fval, unit, parts[next]))
else if (val == "left" || val == "right")
{
bgPositionY += " " + toString("%.0f%s", fval, unit.c_str());
// consume css length
bgPositionX = val;
// consume 'left|right'
next++;
if (next < parts.size() && getCssLength(fval, unit, parts[next]))
{
bgPositionX += " " + toString("%.0f%s", fval, unit.c_str());
// consume css length
next++;
}
}
else if (val == "top" || val == "bottom")
{
bgPositionY = val;
// consume top|bottom
next++;
if (next < parts.size() && getCssLength(fval, unit, parts[next]))
{
bgPositionY += " " + toString("%.0f%s", fval, unit.c_str());
// consume css length
next++;
}
}
}
} while (loop);

Loading…
Cancel
Save