Coverity scan IDF fixes.
* Fix resource leak in idf_parser.cpp * Fix logically dead code in idf_parser.cpp * Fix use after free bug in idf_parser.cpp * Fix unitialized scalar value in idf_parser.cpp * Fix logically dead code in idf_outlines.cpp * Fix unitialized scalar value in idf_outlines.cpp * Fix invalid iterator in idf_common.cpp * Fix unitialized scalar value in vrml_layer.cpp
This commit is contained in:
parent
f2edf02b35
commit
1acfbb0ddd
|
@ -950,7 +950,7 @@ void IDF3::GetOutline( std::list<IDF_SEGMENT*>& aLines,
|
||||||
PrintSeg( *bl );
|
PrintSeg( *bl );
|
||||||
#endif
|
#endif
|
||||||
aOutline.push( *bl );
|
aOutline.push( *bl );
|
||||||
aLines.erase( bl );
|
bl = aLines.erase( bl );
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -982,7 +982,7 @@ void IDF3::GetOutline( std::list<IDF_SEGMENT*>& aLines,
|
||||||
printSeg( *bl );
|
printSeg( *bl );
|
||||||
#endif
|
#endif
|
||||||
aOutline.push( *bl );
|
aOutline.push( *bl );
|
||||||
aLines.erase( bl );
|
bl = aLines.erase( bl );
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -377,7 +377,7 @@ void BOARD_OUTLINE::readOutlines( std::ifstream& aBoardFile, IDF3::IDF_VERSION a
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify winding of previous outline
|
// verify winding of previous outline
|
||||||
if( ( loopidx = 0 && !op->IsCCW() )
|
if( ( loopidx == 0 && !op->IsCCW() )
|
||||||
|| ( loopidx > 0 && op->IsCCW() ) )
|
|| ( loopidx > 0 && op->IsCCW() ) )
|
||||||
{
|
{
|
||||||
ostringstream ostr;
|
ostringstream ostr;
|
||||||
|
@ -2232,10 +2232,11 @@ PLACE_OUTLINE::PLACE_OUTLINE( IDF3_BOARD* aParent )
|
||||||
setParent( aParent );
|
setParent( aParent );
|
||||||
outlineType = OTLN_PLACE;
|
outlineType = OTLN_PLACE;
|
||||||
single = true;
|
single = true;
|
||||||
thickness = 0.0;
|
thickness = -1.0;
|
||||||
side = LYR_INVALID;
|
side = LYR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PLACE_OUTLINE::SetSide( IDF3::IDF_LAYER aSide )
|
bool PLACE_OUTLINE::SetSide( IDF3::IDF_LAYER aSide )
|
||||||
{
|
{
|
||||||
#ifndef DISABLE_IDF_OWNERSHIP
|
#ifndef DISABLE_IDF_OWNERSHIP
|
||||||
|
@ -2424,22 +2425,13 @@ void PLACE_OUTLINE::readData( std::ifstream& aBoardFile, const std::string& aHea
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !GetIDFString( iline, token, quoted, idx ) )
|
if( GetIDFString( iline, token, quoted, idx ) )
|
||||||
{
|
{
|
||||||
ostringstream ostr;
|
|
||||||
|
|
||||||
ostr << "\n* invalid outline: " << GetOutlineTypeString( outlineType ) << "\n";
|
|
||||||
ostr << "* violation: no height specified\n";
|
|
||||||
ostr << "* line: '" << iline << "'\n";
|
|
||||||
ostr << "* file position: " << pos;
|
|
||||||
|
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
std::stringstream teststr;
|
std::stringstream teststr;
|
||||||
teststr << token;
|
teststr << token;
|
||||||
|
|
||||||
teststr >> thickness;
|
teststr >> thickness;
|
||||||
|
|
||||||
if( teststr.fail() )
|
if( teststr.fail() )
|
||||||
{
|
{
|
||||||
ostringstream ostr;
|
ostringstream ostr;
|
||||||
|
@ -2482,6 +2474,25 @@ void PLACE_OUTLINE::readData( std::ifstream& aBoardFile, const std::string& aHea
|
||||||
|
|
||||||
if( thickness < 0.0 )
|
if( thickness < 0.0 )
|
||||||
thickness = 0.0;
|
thickness = 0.0;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// for OTLN_PLACE, thickness may be omitted, but is required for OTLN_PLACE_KEEPOUT
|
||||||
|
if( outlineType == OTLN_PLACE_KEEPOUT )
|
||||||
|
{
|
||||||
|
ostringstream ostr;
|
||||||
|
|
||||||
|
ostr << "\n* invalid outline: " << GetOutlineTypeString( outlineType ) << "\n";
|
||||||
|
ostr << "* violation: missing thickness\n";
|
||||||
|
ostr << "* line: '" << iline << "'\n";
|
||||||
|
ostr << "* file position: " << pos;
|
||||||
|
|
||||||
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
thickness = -1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2574,12 +2585,20 @@ void PLACE_OUTLINE::writeData( std::ofstream& aBoardFile )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// thickness is optional for OTLN_PLACE, but mandatory for OTLN_PLACE_KEEPOUT
|
||||||
|
if( thickness < 0.0 && outlineType == OTLN_PLACE_KEEPOUT)
|
||||||
|
{
|
||||||
|
aBoardFile << "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
aBoardFile << " ";
|
aBoardFile << " ";
|
||||||
|
|
||||||
if( unit != UNIT_THOU )
|
if( unit != UNIT_THOU )
|
||||||
aBoardFile << setiosflags(ios::fixed) << setprecision(5) << thickness << "\n";
|
aBoardFile << setiosflags(ios::fixed) << setprecision(5) << thickness << "\n";
|
||||||
else
|
else
|
||||||
aBoardFile << setiosflags(ios::fixed) << setprecision(1) << (thickness / IDF_THOU_TO_MM) << "\n";
|
aBoardFile << setiosflags(ios::fixed) << setprecision(1) << (thickness / IDF_THOU_TO_MM) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// write RECORD 3
|
// write RECORD 3
|
||||||
writeOutlines( aBoardFile );
|
writeOutlines( aBoardFile );
|
||||||
|
|
|
@ -498,7 +498,6 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IDF3::IDF_LAYER side; // Board Side [TOP/BOTTOM/BOTH ONLY] (IDF spec)
|
IDF3::IDF_LAYER side; // Board Side [TOP/BOTTOM/BOTH ONLY] (IDF spec)
|
||||||
double height; // Max Height (IDF spec)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PLACE_OUTLINE( IDF3_BOARD* aParent );
|
PLACE_OUTLINE( IDF3_BOARD* aParent );
|
||||||
|
|
|
@ -1050,9 +1050,7 @@ bool IDF3_COMPONENT::DelDrill( double aDia, double aXpos, double aYpos )
|
||||||
{
|
{
|
||||||
val = true;
|
val = true;
|
||||||
delete *itS;
|
delete *itS;
|
||||||
drills.erase( itS );
|
itS = drills.erase( itS );
|
||||||
itS = drills.begin();
|
|
||||||
itE = drills.end();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
++itS;
|
++itS;
|
||||||
|
@ -1341,6 +1339,7 @@ IDF3_BOARD::IDF3_BOARD( IDF3::CAD_TYPE aCadType )
|
||||||
brdFileVersion = 0;
|
brdFileVersion = 0;
|
||||||
libFileVersion = 0;
|
libFileVersion = 0;
|
||||||
iRefDes = 0;
|
iRefDes = 0;
|
||||||
|
unit = UNIT_MM;
|
||||||
|
|
||||||
// unlike other outlines which are created as necessary,
|
// unlike other outlines which are created as necessary,
|
||||||
// the board outline always exists and its parent must
|
// the board outline always exists and its parent must
|
||||||
|
@ -2002,14 +2001,13 @@ void IDF3_BOARD::readBrdSection( std::ifstream& aBoardFile, IDF3::FILE_STATE& aB
|
||||||
|
|
||||||
if( olnOther.insert( pair<string, OTHER_OUTLINE*>(op->GetOutlineIdentifier(), op) ).second == false )
|
if( olnOther.insert( pair<string, OTHER_OUTLINE*>(op->GetOutlineIdentifier(), op) ).second == false )
|
||||||
{
|
{
|
||||||
delete op;
|
|
||||||
|
|
||||||
ostringstream ostr;
|
ostringstream ostr;
|
||||||
ostr << "invalid IDF file\n";
|
ostr << "invalid IDF file\n";
|
||||||
ostr << "* Violation of specification. Non-unique ID in OTHER_OUTLINE '";
|
ostr << "* Violation of specification. Non-unique ID in OTHER_OUTLINE '";
|
||||||
ostr << op->GetOutlineIdentifier() << "'\n";
|
ostr << op->GetOutlineIdentifier() << "'\n";
|
||||||
ostr << "* line: '" << iline << "'\n";
|
ostr << "* line: '" << iline << "'\n";
|
||||||
ostr << "* pos: " << pos;
|
ostr << "* pos: " << pos;
|
||||||
|
delete op;
|
||||||
|
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
||||||
}
|
}
|
||||||
|
@ -2491,6 +2489,7 @@ void IDF3_BOARD::readLibSection( std::ifstream& aLibFile, IDF3::FILE_STATE& aLib
|
||||||
ostr << "* Violation of specification: multiple outlines have the same GEOM and PART name\n";
|
ostr << "* Violation of specification: multiple outlines have the same GEOM and PART name\n";
|
||||||
ostr << "* line: '" << iline << "'\n";
|
ostr << "* line: '" << iline << "'\n";
|
||||||
ostr << "* pos: " << pos;
|
ostr << "* pos: " << pos;
|
||||||
|
delete pout;
|
||||||
|
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
||||||
}
|
}
|
||||||
|
@ -2504,6 +2503,7 @@ void IDF3_BOARD::readLibSection( std::ifstream& aLibFile, IDF3::FILE_STATE& aLib
|
||||||
ostr << "* Expecting .ELECTRICAL or .MECHANICAL, got '" << token << "'\n";
|
ostr << "* Expecting .ELECTRICAL or .MECHANICAL, got '" << token << "'\n";
|
||||||
ostr << "* line: '" << iline << "'\n";
|
ostr << "* line: '" << iline << "'\n";
|
||||||
ostr << "* pos: " << pos;
|
ostr << "* pos: " << pos;
|
||||||
|
delete pout;
|
||||||
|
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
|
||||||
}
|
}
|
||||||
|
@ -3429,10 +3429,6 @@ bool IDF3_BOARD::DelBoardDrill( double aDia, double aXpos, double aYpos )
|
||||||
|
|
||||||
switch( keyo )
|
switch( keyo )
|
||||||
{
|
{
|
||||||
case UNOWNED:
|
|
||||||
ostr << "UNOWNED";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ECAD:
|
case ECAD:
|
||||||
ostr << "ECAD";
|
ostr << "ECAD";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -178,6 +178,8 @@ VRML_LAYER::VRML_LAYER()
|
||||||
fix = false;
|
fix = false;
|
||||||
Fault = false;
|
Fault = false;
|
||||||
idx = 0;
|
idx = 0;
|
||||||
|
hidx = 0;
|
||||||
|
eidx = 0;
|
||||||
ord = 0;
|
ord = 0;
|
||||||
glcmd = 0;
|
glcmd = 0;
|
||||||
pholes = NULL;
|
pholes = NULL;
|
||||||
|
|
|
@ -100,7 +100,6 @@ private:
|
||||||
bool fix; // when true, no more vertices may be added by the user
|
bool fix; // when true, no more vertices may be added by the user
|
||||||
int idx; // vertex index (number of contained vertices)
|
int idx; // vertex index (number of contained vertices)
|
||||||
int ord; // vertex order (number of ordered vertices)
|
int ord; // vertex order (number of ordered vertices)
|
||||||
unsigned int idxout; // outline index to first point in 3D outline
|
|
||||||
std::vector<VERTEX_3D*> vertices; // vertices of all contours
|
std::vector<VERTEX_3D*> vertices; // vertices of all contours
|
||||||
std::vector<std::list<int>*> contours; // lists of vertices for each contour
|
std::vector<std::list<int>*> contours; // lists of vertices for each contour
|
||||||
std::vector<bool>pth; // indicates whether a 'contour' is a PTH or not
|
std::vector<bool>pth; // indicates whether a 'contour' is a PTH or not
|
||||||
|
|
Loading…
Reference in New Issue