Handle exceptions in int conversions (#2092)

* RageUtil: Add exception-safe wrappers around std::stoi, stol, stoll

* Replace use of std::stoi with exception-safe StringToInt
This commit is contained in:
Gareth Francis
2021-02-15 12:36:51 -08:00
committed by GitHub
parent c7c54bb013
commit aeb5c7598f
25 changed files with 124 additions and 73 deletions
+1 -1
View File
@@ -607,7 +607,7 @@ bool PlayerOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut
{
// XXX: We know what they want, is there any reason not to handle it?
// Yes. We should be strict in handling the format. -Chris
sErrorOut = ssprintf("Invalid player options \"%s\"; did you mean '*%d'?", s.c_str(), std::stoi(s) );
sErrorOut = ssprintf("Invalid player options \"%s\"; did you mean '*%d'?", s.c_str(), StringToInt(s) );
return false;
}
else