1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0032930: Modeling Algorithms - Crash in PerformIntersectionAtEnd when no face was found

The PerformIntersectionAtEnd code is currently not handling all the faces
correctly. If it retrieves Face[0] as F, it can happen that the previously
ran code didn't actually retrieve any faces in this array at all.

For example when:

* "if (nface==3)" is true
  - "if (!findonf1)" is true (doesn't assign any faces to this array)
  - "if (!findonf2)" is true (doesn't assign any faces to this array)
  - "if (state == ChFiDS_OnSame)" is not true (because it is
    ChFiDS_AllSame)
  - "if (findonf1 && !isOnSame1)" cannot be true (see above, but would
    handle faces)
  - "if (findonf2 && !isOnSame2)" cannot be true (see above, but would
    handle faces)
  - "if (isOnSame2)" is false (but would also handle faces)

Since no faces were assigned here, F would be a NULL face. As result, the
function will crash when trying to access the Surface behind the face via
`BRep_Tool::Surface(F);`.

While the best approach would be to identify the implementation bug in the
algorithm behind PerformIntersectionAtEnd, a check + exception is used
instead because the actual algorithm is not known.

Signed-off-by: Charlemagne Lasse <charlemagnelasse@gmail.com>
This commit is contained in:
Charlemagne Lasse
2022-04-13 11:54:30 +02:00
committed by afokin
parent d30f25e6b1
commit 10a19b2a75
2 changed files with 29 additions and 0 deletions

View File

@@ -2115,6 +2115,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
F=Face[nb-1];
if (!prolface[nb-1]) faceprol[nb-1]=F;
}
if (F.IsNull()) throw Standard_NullObject("IntersectionAtEnd : Trying to intersect with NULL face");
Sfacemoins1=BRep_Tool::Surface(F);
Handle(Geom_Curve) cint;
Handle(Geom2d_Curve) C2dint1, C2dint2,cface,cfacemoins1;