do {
BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream);
mySections.Append(aSection);
- } while
- (!aSection.Name().IsEqual((Standard_CString)SHAPESECTION_POS));
+ } while(!aSection.Name().IsEqual((Standard_CString)SHAPESECTION_POS) && !theIStream.eof());
+
+ if (theIStream.eof()) {
+ // There is no shape section in the file.
+ WriteMessage (aMethStr + "error: shape section is not found");
+ myReaderStatus = PCDM_RS_ReaderException;
+ return;
+ }
+
aDocumentPos = theIStream.tellg(); // position of root label
BinLDrivers_VectorOfDocumentSection::Iterator anIterS (mySections);
// Read attributes:
theIS >> myPAtt;
while (theIS && myPAtt.TypeId() > 0 && // not an end marker ?
- myPAtt.Id() > 0) { // not a garbage ?
+ myPAtt.Id() > 0 && // not a garbage ?
+ !theIS.eof()) {
// get a driver according to TypeId
Handle(BinMDF_ADriver) aDriver = myDrivers->GetDriver (myPAtt.TypeId());
if (!aDriver.IsNull()) {
#if DO_INVERSE
aTag = InverseInt (aTag);
#endif
- while (theIS && aTag >= 0) { // not an end marker ?
+ while (theIS && aTag >= 0 && !theIS.eof()) { // not an end marker ?
// create sub-label
TDF_Label aLab = theLabel.FindChild (aTag, Standard_True);
--- /dev/null
+puts "REQUIRED OCC27667 All: BinLDrivers_DocumentRetrievalDriver: error: shape section is not found"
+puts "REQUIRED OCC27667 All: DDocStd_Open : Error"
+
+puts "================"
+puts "OCC27667"
+puts "================"
+puts ""
+#######################################################################################
+# OCAF binary persistence hangs on reading truncated CBF file
+#######################################################################################
+
+catch { Open [locate_data_file bug27667_broken_cbf.cbf] D }