File 0001-Fix-build-with-VTK-9.0-fix-memory-leak.patch of Package CSXCAD
From 4fb68af94c89bb2eb44d810cbfc043524c024c81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Sun, 7 Jun 2020 23:53:51 +0200
Subject: [PATCH] Fix build with VTK 9.0, fix memory leak
The vertices array contains immutable IDs, which is reflected by the
changed API in VTK 9.0.
As GetNextCell(numP, vertices) overwrites vertices (it is a reference),
the previously pointed to/acllocated array was leaked.
---
src/CSPrimPolyhedronReader.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CSPrimPolyhedronReader.cpp b/src/CSPrimPolyhedronReader.cpp
index 4d44f49..e3d347e 100644
--- a/src/CSPrimPolyhedronReader.cpp
+++ b/src/CSPrimPolyhedronReader.cpp
@@ -163,7 +163,11 @@ bool CSPrimPolyhedronReader::ReadFile()
AddVertex(polydata->GetPoint(n));
vtkIdType numP;
- vtkIdType *vertices = new vtkIdType[10];
+#if VTK_MAJOR_VERSION >= 9
+ vtkIdType const *vertices = nullptr;
+#else
+ vtkIdType *vertices = nullptr;
+#endif
while (verts->GetNextCell(numP, vertices))
{
face f;
--
2.26.2