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

Loading…
Cancel
Save