mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-04-25 09:14:22 +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:
parent
a153b614ea
commit
bca4d66ace
@ -53,18 +53,21 @@ AnyType::operator StringType()
|
||||
|
||||
AnyType::operator PointType()
|
||||
{
|
||||
if(type == TypePoint)
|
||||
if (type == TypePoint)
|
||||
{
|
||||
return PointType(std::get<ui::Point>(value));
|
||||
}
|
||||
else if(type == TypeString)
|
||||
else if (type == TypeString)
|
||||
{
|
||||
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))
|
||||
if(!end.After().size())
|
||||
if (String::Split comma = std::get<String>(value).SplitNumber(x))
|
||||
if (comma.After().BeginsWith(","))
|
||||
{
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user