Improve input validity check in TMVA::MethodKNN::ReadWeightsFromStream.
Improve input validity check in TMVA::MethodKNN::ReadWeightsFromStream.

V663 Infinite loop is possible. The 'cin.eof()' condition is insufficient to break from the loop. Consider adding the 'cin.fail()' function call to the conditional expression. MethodKNN.cxx 602

When working with the std::istream class, calling the eof() function is not enough to terminate the loop. The eof() function will always return false if the data can't be read, and there are no other termination points in this code. To guarantee the termination of the loop, an additional check of the value returned by the fail() function is required:

while (!is.eof() && !is.fail())
{
....
}

As an alternative, it can be rewritten as follows:

while (is)
{
....
}

root-mirror/root,karies/root,karies/root,root-mirror/root,karies/root,karies/root,olifre/root,olifre/root,root-mirror/root,root-mirror/root,karies/root,root-mirror/root,root-mirror/root,root-mirror/root,olifre/root,olifre/root,olifre/root,root-mirror/root,olifre/root,olifre/root,root-mirror/root,karies/root,karies/root,root-mirror/root,olifre/root,olifre/root,karies/root,karies/root,olifre/root,karies/root,karies/root,root-mirror/root,olifre/root