Salome HOME
Fix to avoid crash in the issue #2360
authormpv <mpv@opencascade.com>
Wed, 13 Dec 2017 11:00:19 +0000 (14:00 +0300)
committermpv <mpv@opencascade.com>
Wed, 13 Dec 2017 11:00:19 +0000 (14:00 +0300)
src/Model/Model_Objects.cpp

index 35df5f6816e3d7f3e54d3ad451de29d91f38efff..77fd4bdfaa4473e8ab87594cfe25baf0cd166622 100644 (file)
@@ -564,6 +564,9 @@ ObjectPtr Model_Objects::object(const std::string& theGroupID,
     return ObjectPtr();
   createHistory(theGroupID);
   const std::string& aGroupID = groupNameFoldering(theGroupID, theAllowFolder);
+  const std::vector<ObjectPtr>& aVec = myHistory[theGroupID];
+  if (aVec.size() <= theIndex)
+    return aVec[aVec.size() - 1]; // too high index requested (to avoid crash in #2360)
   return aGroupID.empty() ? myHistory[theGroupID][theIndex] : myHistory[aGroupID][theIndex];
 }