mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Fix: strToVec enters infinite loop and exhausts memory if operator>> fails before the end of string, e.g. if parsing "0_0_0" for momentum instead of "0 0 0".
This commit is contained in:
parent
dbaeefaeef
commit
4a4b9e305d
@ -432,12 +432,10 @@ namespace Grid {
|
|||||||
std::vector<T> strToVec(const std::string s)
|
std::vector<T> strToVec(const std::string s)
|
||||||
{
|
{
|
||||||
std::istringstream sstr(s);
|
std::istringstream sstr(s);
|
||||||
T buf;
|
|
||||||
std::vector<T> v;
|
std::vector<T> v;
|
||||||
|
|
||||||
while(!sstr.eof())
|
for(T buf; sstr >> buf;)
|
||||||
{
|
{
|
||||||
sstr >> buf;
|
|
||||||
v.push_back(buf);
|
v.push_back(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user