Fix possible game crash when using invalid coordinates in !bubble

Point arguments are supposed to look like "x,y", but if you gave it anything after y, it would crash. The comma split data is stored by reference, but the String it was referencing goes out of scope and is potentially destructed. Fix it by expliticly keeping a String object in scope until we're done.
This commit is contained in:
jacob1
2025-02-12 23:07:01 -05:00
parent a153b614ea
commit bca4d66ace

View File

@@ -62,9 +62,12 @@ AnyType::operator PointType()
int x, y;
if (String::Split comma = std::get<String>(value).SplitNumber(x))
if (comma.After().BeginsWith(","))
if(String::Split end = comma.After().Substr(1).SplitNumber(y))
{
String after = comma.After().Substr(1);
if (String::Split end = after.SplitNumber(y))
if (!end.After().size())
return PointType(x, y);
}
throw InvalidConversionException(type, TypePoint);
}
else