PVS: V1024 The 'file' stream is checked for EOF before reading from it, but is not checked after reading. Potential use of invalid data

This commit is contained in:
wmayer
2019-03-13 13:34:45 +01:00
parent 56b9d509a1
commit 23bc00e1a1
6 changed files with 8 additions and 17 deletions

View File

@@ -155,9 +155,8 @@ App::DocumentObjectExecReturn *FeaturePage::execute(void)
ostringstream ofile;
string tempendl = "--endOfLine--";
while (!file.eof())
while (getline (file,line))
{
getline (file,line);
// check if the marker in the template is found
if(line.find("<!-- DrawingContent -->") == string::npos)
// if not - write through
@@ -259,8 +258,7 @@ std::vector<std::string> FeaturePage::getEditableTextsFromTemplate(void) const {
}
string tline, tfrag;
ifstream tfile (tfi.filePath().c_str());
while (!tfile.eof()) {
getline (tfile,tline);
while (getline (tfile,tline)) {
tfrag += tline;
tfrag += "--endOfLine--";
}

View File

@@ -88,10 +88,8 @@ void pagesize(string & page_template, int dims[4], int block[4])
try
{
while (!file.eof())
while (getline (file,line))
{
getline (file,line);
if (line.find("<!-- Working space") != string::npos)
{
sscanf(line.c_str(), "%*s %*s %*s %d %d %d %d", &dims[0], &dims[1], &dims[2], &dims[3]); //eg " <!-- Working space 10 10 410 287 -->"

View File

@@ -87,8 +87,7 @@ App::DocumentObjectExecReturn *LuxProject::execute(void)
ofstream ofile(tempName.c_str());
// copy the input of the resource file
while (!file.eof()) {
getline (file,line);
while (getline (file,line)) {
// check if the marker in the template is found
if(line.find("#RaytracingContent") == string::npos) {
if(line.find("#RaytracingCamera") == string::npos) {

View File

@@ -86,8 +86,7 @@ App::DocumentObjectExecReturn *RayProject::execute(void)
ofstream ofile(tempName.c_str());
// copy the input of the resource file
while (!file.eof()) {
getline (file,line);
while (getline (file,line)) {
// check if the marker in the template is found
if(line.find("//RaytracingContent") == string::npos)
// if not - write through

View File

@@ -156,9 +156,8 @@ App::DocumentObjectExecReturn * DrawSVGTemplate::execute(void)
//remove DrawingContent comment line
//change line endings
//capture TitleBlock dimensions
while (!inTemplate.eof())
while (getline(inTemplate,line))
{
getline(inTemplate,line);
// copy every line except the DrawingContent comment?
if(line.find("<!-- DrawingContent -->") == string::npos) {
// if not - write through
@@ -287,8 +286,7 @@ std::map<std::string, std::string> DrawSVGTemplate::getEditableTextsFromTemplate
}
string tline, tfrag;
ifstream tfile (tfi.filePath().c_str());
while (!tfile.eof()) {
getline (tfile,tline);
while (getline (tfile,tline)) {
tfrag += tline;
tfrag += "--endOfLine--";
}

View File

@@ -154,9 +154,8 @@ void QGISVGTemplate::createClickHandles(void)
//read all of PageResult into oStream (except the DrawingContent marker comment - why??)
std::ifstream ifile (fi.filePath().c_str());
while (!ifile.eof())
while (std::getline(ifile,line))
{
std::getline(ifile,line);
// check if the marker in the template is found
if(line.find("<!-- DrawingContent -->") == std::string::npos) {
// if not - write line to oStream