← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] IDF code: fixing problems reported by coverity

 

My bad; I didn't quite get the logical flow and missed quite a few more
deletes.

I've attached a patch that should fix that as well as 2 issues in
'export_vrml.cpp'

Since the issue in idf_parser.cpp can only be tripped if the input file is
defective
and the issues in export_vrml.cpp are minor (for various reasons they do not
constitute bugs as the code stands) I'd recommend applying the patch now
and I'll check the status again whenever the next coverity scan is done.

I haven't been able to take ownership of any of the issues; is there an
admin
privilege somewhere or am I missing something?

- Cirilo


On Tue, Feb 17, 2015 at 1:47 PM, Mark Roszko <mark.roszko@xxxxxxxxx> wrote:

> Coverity reports #102373 was not fixed.
>
> If while( aLibFile.good() ) is not true, it'll end up exiting the
> function with pout not freed.
>
> Also this is a good example of why you should mark issues you fix or
> ignore in Coverity. It's easier to check later if it got fixed.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
>
=== modified file 'pcbnew/exporters/export_vrml.cpp'
--- pcbnew/exporters/export_vrml.cpp	2015-01-15 20:01:53 +0000
+++ pcbnew/exporters/export_vrml.cpp	2015-02-17 03:32:31 +0000
@@ -185,7 +185,11 @@
         colors[ VRML_COLOR_TIN ]    = VRML_COLOR( .749, .756, .761, .749, .756, .761,
                                                   0, 0, 0, 0.8, 0, 0.8 );
 
-        precision = 5;
+        plainPCB = false;
+        SetScale( 1.0 );
+        SetOffset( 0.0, 0.0 );
+        s_text_layer = F_Cu;
+        s_text_width = 1;
     }
 
     VRML_COLOR& GetColor( VRML_COLOR_INDEX aIndex )
@@ -889,11 +893,11 @@
         const CPOLYGONS_LIST& poly = zone->GetFilledPolysList();
         int nvert = poly.GetCornersCount();
         int i = 0;
+        bool cutout = false;
 
         while( i < nvert )
         {
             int seg = vl->NewContour();
-            bool first = true;
 
             if( seg < 0 )
                 break;
@@ -914,10 +918,10 @@
 
             // KiCad ensures that the first polygon is the outline
             // and all others are holes
-             vl->EnsureWinding( seg, first ? false : true );
+             vl->EnsureWinding( seg, cutout );
 
-            if( first )
-                first = false;
+             if( !cutout )
+                 cutout = true;
 
             ++i;
         }

=== modified file 'utils/idftools/idf_parser.cpp'
--- utils/idftools/idf_parser.cpp	2015-02-16 17:45:37 +0000
+++ utils/idftools/idf_parser.cpp	2015-02-17 03:18:31 +0000
@@ -2425,12 +2425,18 @@
         while( !FetchIDFLine( aLibFile, iline, isComment, pos ) && aLibFile.good() );
 
         if( !aLibFile.good() && !aLibFile.eof() )
+        {
+            delete pout;
             throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
                               "problems reading library section" ) );
+        }
 
         // no data was read; this only happens at eof()
         if( iline.empty() )
+        {
+            delete pout;
             return;
+        }
 
         if( isComment )
         {
@@ -2448,6 +2454,7 @@
             ostr << "* Violation of specification: quoted string where .ELECTRICAL or .MECHANICAL expected\n";
             ostr << "* line: '" << iline << "'\n";
             ostr << "* pos: " << pos;
+            delete pout;
 
             throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
         }
@@ -2509,6 +2516,8 @@
         }
     }
 
+    delete pout;
+
     if( !aLibFile.eof() )
         throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
                           "problems reading IDF library file" ) );


Follow ups

References