← Back to team overview

kicad-developers team mailing list archive

Re: New fix for bug 1663173

 

Hi,

Sorry, corrected patch attached.

Regards
Le 18/10/2017 à 19:31, Wayne Stambaugh a écrit :
> Hi Jean-Samuel,
> 
> There are a few coding policy violations in your patch.
> 
> if( outline.OutlineCount() > 0) {
> 
> should be:
> 
> if( outline.OutlineCount() > 0 )
> {
> 
> This occurs several times.  Please fix this as resubmit the patch.
> 
> Thanks,
> 
> Wayne
> 
> On 10/18/2017 8:58 AM, Jean-Samuel Reynaud wrote:
>> Hi all,
>>
>> Since some recent modifications (I don't search from what version
>> exactly), bug 1663173 is coming back...
>>
>> See original description : https://bugs.launchpad.net/kicad/+bug/1663173
>>
>> Please find attached the patch to fix it.
>>
>> Following this issue I have two comments:
>>
>> - For any usage of "poly->Point( 0 )" or anything like, this should be
>> preceded by a check if value "0" is a valid value.
>>  Like this:
>>                 if( poly->PointCount() > 0)
>>                 {
>>                    // Use of poly->Point( 0 )
>>
>> Same with Outline :
>>             if( outline.OutlineCount() > 0) {
>>                 // Use of outline.Outline( 0 );
>> Or any other way to ensure the index X (with X=0 in thoses case) is a
>> valid index...
>>
>> - Is it really logic to allow negative clearance in pads ? Should not be
>> an absolute value ? In this case, interface should avoid this case...
>>
>> Regards,
>>
>>
>>
>> _______________________________________________
>> 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
>>
> 
> _______________________________________________
> 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
> 

>From 1616c6519edb385b8e5b7af348ed480583589e9a Mon Sep 17 00:00:00 2001
From: Jean-Samuel Reynaud <js.reynaud@xxxxxxxxx>
Date: Thu, 19 Oct 2017 10:27:00 +0200
Subject: [PATCH] Fix crash with clearance is "too" negative. Same bug as
 #1663173
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.7.4"

This is a multi-part message in MIME format.
--------------2.7.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


Fixes: lp:1663173
* https://bugs.launchpad.net/kicad/+bug/1663173
---
 pcbnew/class_pad_draw_functions.cpp | 53 ++++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 16 deletions(-)


--------------2.7.4
Content-Type: text/x-patch; name="0001-Fix-crash-with-clearance-is-too-negative.-Same-bug-a.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Fix-crash-with-clearance-is-too-negative.-Same-bug-a.patch"

diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp
index 9d270b0..620e0b4 100644
--- a/pcbnew/class_pad_draw_functions.cpp
+++ b/pcbnew/class_pad_draw_functions.cpp
@@ -402,11 +402,17 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
             TransformShapeWithClearanceToPolygon( outline, aDrawInfo.m_PadClearance, SEGCOUNT, 1.0 );
 
             // Draw the polygon: Inflate creates only one convex polygon
-            SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
+            if( outline.OutlineCount() > 0 )
+            {
+                SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
 
-            GRClosedPoly( aClipBox, aDC, poly.PointCount(),
-                          (wxPoint*)&poly.Point( 0 ), false, 0,
-                          aDrawInfo.m_Color, aDrawInfo.m_Color );
+                if( poly.PointCount() > 0 )
+                {
+                    GRClosedPoly( aClipBox, aDC, poly.PointCount(),
+                                  (wxPoint*)&poly.Point( 0 ), false, 0,
+                                  aDrawInfo.m_Color, aDrawInfo.m_Color );
+                }
+            }
         }
         break;
 
@@ -434,11 +440,17 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
             TransformRoundRectToPolygon( outline, shape_pos, size, GetOrientation(),
                                          corner_radius, 64 );
 
-            SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
+            if( outline.OutlineCount() > 0 )
+            {
+                SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
 
-            GRClosedPoly( aClipBox, aDC, poly.PointCount(),
-                          (wxPoint*)&poly.Point( 0 ), aDrawInfo.m_ShowPadFilled, 0,
-                          aDrawInfo.m_Color, aDrawInfo.m_Color );
+                if( poly.PointCount() > 0 )
+                {
+                    GRClosedPoly( aClipBox, aDC, poly.PointCount(),
+                                  (wxPoint*)&poly.Point( 0 ), aDrawInfo.m_ShowPadFilled, 0,
+                                  aDrawInfo.m_Color, aDrawInfo.m_Color );
+                }
+            }
         }
 
         if( aDrawInfo.m_PadClearance )
@@ -452,12 +464,18 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
             TransformRoundRectToPolygon( outline, shape_pos, size, GetOrientation(),
                                      corner_radius, 32 );
 
-            // Draw the polygon: Inflate creates only one convex polygon
-            SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 );
+            if( outline.OutlineCount() > 0 )
+            {
+                // Draw the polygon: Inflate creates only one convex polygon
+                SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 );
 
-            GRClosedPoly( aClipBox, aDC, clearance_poly.PointCount(),
-                          (wxPoint*)&clearance_poly.Point( 0 ), false, 0,
-                          aDrawInfo.m_Color, aDrawInfo.m_Color );
+                if( clearance_poly.PointCount() > 0 )
+                {
+                    GRClosedPoly( aClipBox, aDC, clearance_poly.PointCount(),
+                                  (wxPoint*)&clearance_poly.Point( 0 ), false, 0,
+                                  aDrawInfo.m_Color, aDrawInfo.m_Color );
+                }
+            }
         }
     }
         break;
@@ -541,9 +559,12 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
             {
                 poly = &clearance_outline.Outline( jj );
 
-                GRClosedPoly( aClipBox, aDC, poly->PointCount(),
-                              (wxPoint*)&poly->Point( 0 ), false, 0,
-                              aDrawInfo.m_Color, aDrawInfo.m_Color );
+                if( poly->PointCount() > 0 )
+                {
+                    GRClosedPoly( aClipBox, aDC, poly->PointCount(),
+                                  (wxPoint*)&poly->Point( 0 ), false, 0,
+                                  aDrawInfo.m_Color, aDrawInfo.m_Color );
+                }
             }
         }
         break;

--------------2.7.4--



Follow ups

References