From 1ab742b0a6db72270da259633029b45c20ffd708 Mon Sep 17 00:00:00 2001
From: Spiros Tsalikis <spiros.tsalikis@kitware.com>
Date: Wed, 18 Dec 2024 12:43:37 -0500
Subject: [PATCH] vtkHigherOrderTetra: Add size check

---
 Common/DataModel/vtkHigherOrderTetra.cxx | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Common/DataModel/vtkHigherOrderTetra.cxx b/Common/DataModel/vtkHigherOrderTetra.cxx
index 12abcbbf27c..6a2d28eee0b 100644
--- a/Common/DataModel/vtkHigherOrderTetra.cxx
+++ b/Common/DataModel/vtkHigherOrderTetra.cxx
@@ -780,6 +780,14 @@ void vtkHigherOrderTetra::SetParametricCoords()
     double order_d = static_cast<vtkIdType>(this->GetOrder());
     this->PointParametricCoordinates->SetNumberOfPoints(nPoints);
 
+#ifdef ENABLE_CACHING
+    if (static_cast<vtkIdType>(this->BarycentricIndexMap.size()) !=
+      4 * this->GetPointIds()->GetNumberOfIds())
+    {
+      vtkWarningMacro(<< this->GetClassName() << " has not been initialized");
+      return;
+    }
+#endif
     vtkIdType bindex[4];
     for (vtkIdType p = 0; p < nPoints; p++)
     {
-- 
GitLab