From d47caf019fd136f4bf9dc087ff6a82ec46ac2fe2 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 9 Nov 2017 12:22:15 +0100
Subject: [PATCH] add some sanity checks on angles for cylinders and spheres

---
 Geo/GModelIO_OCC.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp
index d4e5b41e72..e3fb65ccf2 100644
--- a/Geo/GModelIO_OCC.cpp
+++ b/Geo/GModelIO_OCC.cpp
@@ -1344,6 +1344,10 @@ bool OCC_Internals::_makeSphere(TopoDS_Solid &result, double xc, double yc, doub
     Msg::Error("Sphere radius should be positive");
     return false;
   }
+  if(angle3 <= 0 || angle3 > 2 * M_PI){
+    Msg::Error("Cannot build sphere with angle <= 0 or angle > 2*Pi");
+    return false;
+  }
   try{
     gp_Pnt p(xc, yc, zc);
     BRepPrimAPI_MakeSphere s(p, radius, angle1, angle2, angle3);
@@ -1425,6 +1429,10 @@ bool OCC_Internals::_makeCylinder(TopoDS_Solid &result, double x, double y, doub
     Msg::Error("Cannot build cylinder of zero height");
     return false;
   }
+  if(angle <= 0 || angle > 2 * M_PI){
+    Msg::Error("Cannot build cylinder with angle <= 0 or angle > 2*Pi");
+    return false;
+  }
   try{
     gp_Pnt aP(x, y, z);
     gp_Vec aV(dx / H, dy / H, dz / H);
-- 
GitLab