Examples of errors detected by the V663 diagnostic
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.
POCO C++ Libraries
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. Util inifileconfiguration.cpp 86
void IniFileConfiguration::load(std::istream& istr)
{
_map.clear();
_sectionKey.clear();
while (!istr.eof())
{
parseLine(istr);
}
}
Similar errors can be found in some other places:
- 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. Util propertyfileconfiguration.cpp 79
OpenMW
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. components translation.cpp 45
void Storage::loadDataFromStream(
ContainerType& container, std::istream& stream)
{
std::string line;
while (!stream.eof())
{
std::getline( stream, line );
....
}
....
}
Grassroots DICOM library (GDCM)
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. gdcmdataset.txx 59
template <typename TDE, typename TSwap>
std::istream &DataSet::Read(std::istream &is) {
DataElement de;
while( !is.eof() && de.Read<TDE,TSwap>(is) )
{
//std::cerr << "DEBUG:" << de << std::endl;
InsertDataElement( de );
}
return is;
}
Similar errors can be found in some other places:
- 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. gdcmdataset.txx 70
- 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. gdcmdataset.txx 84
- 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. gdcmdataset.txx 105
- And 3 additional diagnostic messages.
ITK
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. metautils.cxx 998
static bool MET_SkipToVal(METAIO_STREAM::istream &fp)
{
....
while( !fp.eof() && c != MET_SeperatorChar && c != ':' )
{
c = fp.get();
}
....
}
Similar errors can be found in some other places:
- 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. metautils.cxx 1003
- 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. metautils.cxx 1060
- 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. metautils.cxx 1066
- And 1 additional diagnostic messages.
SETI@home
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. sqlblob.h 58
template <typename T>
std::istream &operator >>(std::istream &i, sqlblob<T> &b)
{
....
while (!i.eof())
{
i >> tmp;
buf+=(tmp+' ');
}
....
}
GNU Octave
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. ls-mat-ascii.cc 75
static std::string get_mat_data_input_line(std::istream& is)
{
....
do
{
while (is.get(c))
{
....
}
}
while (!(have_data || is.eof()));
....
}
NCBI Genome Workbench
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. ncbicgi.cpp 1564
typedef std::istream CNcbiIstream;
void CCgiRequest::Serialize(CNcbiOstream& os) const
{
....
CNcbiIstream* istrm = GetInputStream();
if (istrm) {
char buf[1024];
while(!istrm->eof()) {
istrm->read(buf, sizeof(buf));
os.write(buf, istrm->gcount());
}
}
}
ROOT
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
void TMVA::MethodKNN::ReadWeightsFromStream(std::istream& is)
{
....
while (!is.eof()) {
std::string line;
std::getline(is, line);
if (line.empty() || line.find("#") != std::string::npos) {
continue;
}
....
}
....
}
FreeCAD
V663 [CWE-834] 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. zipheadio.h 84
inline uint32 readUint32 ( istream &is ) {
static const int buf_len = sizeof ( uint32 ) ;
unsigned char buf [ buf_len ] ;
int rsf = 0 ;
std::streampos original_pos = is.tellg() ;
while ( rsf < buf_len && !is.eof() ) {
is.read ( reinterpret_cast< char * >( buf ) + rsf, buf_len - rsf ) ;
rsf += static_cast< int >( is.gcount () ) ;
}
....
}
Similar errors can be found in some other places:
- V663 [CWE-834] 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. zipheadio.h 106
OpenVINO
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. onnx_model_validator.cpp 168
bool is_valid_model(std::istream& model)
{
const size_t EXPECTED_FIELDS_FOUND = 3u;
std::unordered_set<::onnx::Field, std::hash<int>> onnx_fields_found = {};
try
{
while (!model.eof() && onnx_fields_found.size() < EXPECTED_FIELDS_FOUND)
{
const auto field = ::onnx::decode_next_field(model);
....
}
return onnx_fields_found.size() == EXPECTED_FIELDS_FOUND;
}
catch (....)
{
return false;
}
}