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 20:36:51 +00:00
committed by GitHub
parent c7c54bb013
commit aeb5c7598f
25 changed files with 124 additions and 73 deletions
+2 -2
View File
@@ -452,13 +452,13 @@ void actor_template_t::load_frames_from_file(RString const& fname, RString const
RString field_type= attr->first.Left(5);
if(field_type == "Frame")
{
int id= std::stoi(attr->first.Right(attr->first.size()-5));
int id= StringToInt(attr->first.Right(attr->first.size()-5));
make_space_for_frame(id);
attr->second->GetValue(frames[id].frame);
}
else if(field_type == "Delay")
{
int id= std::stoi(attr->first.Right(attr->first.size()-5));
int id= StringToInt(attr->first.Right(attr->first.size()-5));
make_space_for_frame(id);
attr->second->GetValue(frames[id].delay);
}