← Back to team overview

kicad-developers team mailing list archive

[PATCH] GAL coverity fixes: uninitialised members

 

Hi,

Quick patch to init some GAL class members.

I think most (all?) of these would /eventually/ get set correctly in a
way Coverity doesn't see, but it's good to keep as much as possible in
a sane state!

Cheers,

John
From a25074f51aa5d94815fa581aeed27928d218e243 Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Thu, 30 Mar 2017 15:52:40 +0800
Subject: [PATCH] Init GAL class members (Coverity fixes)

Fixes: CID 157139 (GAL)
       CID 157138 (CAIRO_GAL)
---
 common/gal/cairo/cairo_gal.cpp            | 19 ++++++++++++++++---
 common/gal/graphics_abstraction_layer.cpp |  1 +
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp
index 902624750..cd338d46e 100644
--- a/common/gal/cairo/cairo_gal.cpp
+++ b/common/gal/cairo/cairo_gal.cpp
@@ -52,11 +52,24 @@ CAIRO_GAL::CAIRO_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions,
     mouseListener = aMouseListener;
     paintListener = aPaintListener;
 
-    // Initialize the flags
+    // Initialise grouping
     isGrouping          = false;
-    isInitialized       = false;
-    validCompositor     = false;
+    isElementAdded      = false;
     groupCounter        = 0;
+    currentGroup        = nullptr;
+
+    // Initialise compositing state
+    mainBuffer          = 0;
+    overlayBuffer       = 0;
+    validCompositor     = false;
+    SetTarget( TARGET_NONCACHED );
+
+    // Initialise Cairo state
+    cairo_matrix_init_identity ( &cairoWorldScreenMatrix );
+    currentContext      = nullptr;
+    context             = nullptr;
+    surface             = nullptr;
+    isInitialized       = false;
 
     // Connecting the event handlers
     Connect( wxEVT_PAINT,       wxPaintEventHandler( CAIRO_GAL::onPaint ) );
diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp
index ea839b32a..af3d04b60 100644
--- a/common/gal/graphics_abstraction_layer.cpp
+++ b/common/gal/graphics_abstraction_layer.cpp
@@ -55,6 +55,7 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) :
     SetFlip( false, false );
     SetLineWidth( 1.0 );
     computeWorldScale();
+    SetAxesEnabled( false );
 
     // Set grid defaults
     SetGridVisibility( true );
-- 
2.12.0


Follow ups