1 From 7135f862820948c522eaabcc6b9ff5c91fb0ae46 Mon Sep 17 00:00:00 2001
2 From: Louis Gombert <louis.gombert@kitware.com>
3 Date: Wed, 25 Sep 2024 16:38:20 +0200
4 Subject: [PATCH] EnSightGoldBinaryReader: fix int overflow when opening large
7 Convert int to vtkIdType when necessary
9 (cherry picked from commit 3d830296ece3038d3ab03d195db3200604c4c27c)
11 IO/EnSight/vtkEnSightGoldBinaryReader.cxx | 29 +++++++++++------------
12 IO/EnSight/vtkEnSightGoldBinaryReader.h | 2 +-
13 2 files changed, 15 insertions(+), 16 deletions(-)
15 diff --git a/VTK/IO/EnSight/vtkEnSightGoldBinaryReader.cxx b/VTK/IO/EnSight/vtkEnSightGoldBinaryReader.cxx
16 index 9ec5d94457..ede20bbf3f 100644
17 --- a/VTK/IO/EnSight/vtkEnSightGoldBinaryReader.cxx
18 +++ b/VTK/IO/EnSight/vtkEnSightGoldBinaryReader.cxx
19 @@ -825,7 +825,7 @@ int vtkEnSightGoldBinaryReader::SkipUnstructuredGrid(char line[256])
21 vtkDebugMacro("nsided");
22 int* numNodesPerElement;
24 + vtkIdType numNodes = 0;
26 // cellType = vtkEnSightReader::NSIDED;
27 this->ReadInt(&numElements);
28 @@ -2112,8 +2112,8 @@ int vtkEnSightGoldBinaryReader::CreateUnstructuredGridOutput(
30 vtkDebugMacro("nsided");
31 int* numNodesPerElement;
34 + vtkIdType numNodes = 0;
35 + vtkIdType nodeCount = 0;
37 cellType = vtkEnSightReader::NSIDED;
38 this->ReadInt(&numElements);
39 @@ -2160,7 +2160,7 @@ int vtkEnSightGoldBinaryReader::CreateUnstructuredGridOutput(
40 // skipping ghost cells
41 vtkDebugMacro("g_nsided");
42 int* numNodesPerElement;
44 + vtkIdType numNodes = 0;
46 // cellType = vtkEnSightReader::NSIDED;
47 this->ReadInt(&numElements);
48 @@ -2390,12 +2390,12 @@ int vtkEnSightGoldBinaryReader::CreateUnstructuredGridOutput(
50 int* numNodesPerElement;
57 - int elementNodeCount = 0;
58 + vtkIdType numPts = 0;
59 + vtkIdType numFaces = 0;
60 + vtkIdType numNodes = 0;
61 + vtkIdType faceCount = 0;
62 + vtkIdType nodeCount = 0;
63 + vtkIdType elementNodeCount = 0;
65 cellType = vtkEnSightReader::NFACED;
66 this->ReadInt(&numElements);
67 @@ -2463,10 +2463,9 @@ int vtkEnSightGoldBinaryReader::CreateUnstructuredGridOutput(
68 this->ReadIntArray(nodeIdList, numNodes);
71 - int k; // indexing each node Id of a face
72 - int faceIdx = 0; // indexing faces throughout all polyhedra
73 - int nodeIdx = 0; // indexing nodes throughout all polyhedra
74 - int arayIdx = 0; // indexing the array of Ids (info of faces)
75 + int k; // indexing each node Id of a face
76 + vtkIdType faceIdx = 0; // indexing faces throughout all polyhedra
77 + vtkIdType nodeIdx = 0; // indexing nodes throughout all polyhedra
78 vtkIdType* faceAry = nullptr; // array of Ids describing a vtkPolyhedron
81 @@ -3402,7 +3401,7 @@ int vtkEnSightGoldBinaryReader::ReadFloat(float* result)
83 // Internal function to read an integer array.
84 // Returns zero if there was an error.
85 -int vtkEnSightGoldBinaryReader::ReadIntArray(int* result, int numInts)
86 +int vtkEnSightGoldBinaryReader::ReadIntArray(int* result, vtkIdType numInts)
90 diff --git a/VTK/IO/EnSight/vtkEnSightGoldBinaryReader.h b/VTK/IO/EnSight/vtkEnSightGoldBinaryReader.h
91 index dd88876ad9..31bd8faebd 100644
92 --- a/VTK/IO/EnSight/vtkEnSightGoldBinaryReader.h
93 +++ b/VTK/IO/EnSight/vtkEnSightGoldBinaryReader.h
94 @@ -188,7 +188,7 @@ protected:
95 * Internal function to read in an integer array.
96 * Returns zero if there was an error.
98 - int ReadIntArray(int* result, int numInts);
99 + int ReadIntArray(int* result, vtkIdType numInts);
102 * Internal function to read in a single long.