mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-21 15:41:35 +02:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user