From 0a0eec807ddf861841f628bb7b533ead4ab0a852 Mon Sep 17 00:00:00 2001 From: abv Date: Thu, 8 Mar 2018 09:56:01 +0300 Subject: [PATCH] 0027070: Segfault when transferring HLR-created shapes via STEPControl_Writer Added protection against null shape on writing: status IFSelect_RetVoid will be returned in such case (instead of access violation) --- src/XSControl/XSControl_WorkSession.cxx | 5 ++++- tests/bugs/step/bug27070 | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/step/bug27070 diff --git a/src/XSControl/XSControl_WorkSession.cxx b/src/XSControl/XSControl_WorkSession.cxx index 1f8caedac7..0ffc9fdc3e 100644 --- a/src/XSControl/XSControl_WorkSession.cxx +++ b/src/XSControl/XSControl_WorkSession.cxx @@ -458,7 +458,10 @@ IFSelect_ReturnStatus XSControl_WorkSession::TransferWriteShape (const TopoDS_Sh IFSelect_ReturnStatus status; if (myController.IsNull()) return IFSelect_RetError; const Handle(Interface_InterfaceModel) &model = Model(); - if (model.IsNull()) return IFSelect_RetVoid; + if (model.IsNull() || shape.IsNull()) + { + return IFSelect_RetVoid; + } status = myTransferWriter->TransferWriteShape (model,shape); // qui s occupe de tout, try/catch inclus diff --git a/tests/bugs/step/bug27070 b/tests/bugs/step/bug27070 new file mode 100644 index 0000000000..250204c301 --- /dev/null +++ b/tests/bugs/step/bug27070 @@ -0,0 +1,8 @@ +puts "# =======================================================================" +puts "# 0027070: Segfault when transferring HLR-created shapes via STEPControl_Writer" +puts "# =======================================================================" +puts "" + +puts "Check that writing null shape does not produce access violation" +puts "REQUIRED ALL: Error: translation failed, status = 0" +stepwrite a a