File 0001-Fix-use-of-unitialized-stlgeometry-member-in-constru.patch of Package netgen
From 80466f3c7ea1496d35b31d906fd8cc9784663298 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Wed, 13 Jul 2022 12:09:39 +0200
Subject: [PATCH] Fix use of unitialized stlgeometry member in constructor
stlgeometry is a private member of VisualSceneSTLGeometry/Meshing, and
can't point to any valid geometry when the constructor runs, so remove
any dereferences there.
Remove the misleading extern declaration of netgen::stlgeometry.
---
libsrc/stlgeom/vsstl.cpp | 3 ---
libsrc/stlgeom/vsstl.hpp | 4 ++--
libsrc/visualization/stlmeshing.cpp | 3 ---
3 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/libsrc/stlgeom/vsstl.cpp b/libsrc/stlgeom/vsstl.cpp
index 854909d8..0f450038 100644
--- a/libsrc/stlgeom/vsstl.cpp
+++ b/libsrc/stlgeom/vsstl.cpp
@@ -21,7 +21,6 @@ namespace netgen
/* *********************** Draw STL Geometry **************** */
-extern STLGeometry * stlgeometry;
DLL_HEADER extern shared_ptr<Mesh> mesh;
@@ -33,8 +32,6 @@ VisualSceneSTLMeshing :: VisualSceneSTLMeshing ()
{
selecttrig = 0;
nodeofseltrig = 1;
- stlgeometry->SetSelectTrig(selecttrig);
- stlgeometry->SetNodeOfSelTrig(nodeofseltrig);
}
VisualSceneSTLMeshing :: ~VisualSceneSTLMeshing ()
diff --git a/libsrc/stlgeom/vsstl.hpp b/libsrc/stlgeom/vsstl.hpp
index 6d4a6490..f6995d37 100644
--- a/libsrc/stlgeom/vsstl.hpp
+++ b/libsrc/stlgeom/vsstl.hpp
@@ -13,7 +13,7 @@ namespace netgen
class NGGUI_API VisualSceneSTLGeometry : public VisualScene
{
NgArray<int> trilists;
- class STLGeometry * stlgeometry;
+ class STLGeometry * stlgeometry = nullptr;
public:
VisualSceneSTLGeometry ();
@@ -29,7 +29,7 @@ namespace netgen
{
NgArray<int> trilists;
int selecttrig, nodeofseltrig;
- class STLGeometry * stlgeometry;
+ class STLGeometry * stlgeometry = nullptr;
public:
VisualSceneSTLMeshing ();
diff --git a/libsrc/visualization/stlmeshing.cpp b/libsrc/visualization/stlmeshing.cpp
index 70699c56..b3f812e3 100644
--- a/libsrc/visualization/stlmeshing.cpp
+++ b/libsrc/visualization/stlmeshing.cpp
@@ -19,7 +19,6 @@ namespace netgen
/* *********************** Draw STL Geometry **************** */
-extern STLGeometry * stlgeometry;
extern AutoPtr<Mesh> mesh;
@@ -33,8 +32,6 @@ VisualSceneSTLMeshing :: VisualSceneSTLMeshing ()
{
selecttrig = 0;
nodeofseltrig = 1;
- stlgeometry->SetSelectTrig(selecttrig);
- stlgeometry->SetNodeOfSelTrig(nodeofseltrig);
}
VisualSceneSTLMeshing :: ~VisualSceneSTLMeshing ()
--
2.36.1