mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0027667: OCAF binary persistence hangs on reading truncated CBF file
A check on "end of file" is added to the reader.
This commit is contained in:
parent
261b7d9e8a
commit
5ecc46c08e
@ -233,8 +233,15 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
|
|||||||
do {
|
do {
|
||||||
BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream);
|
BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream);
|
||||||
mySections.Append(aSection);
|
mySections.Append(aSection);
|
||||||
} while
|
} while(!aSection.Name().IsEqual((Standard_CString)SHAPESECTION_POS) && !theIStream.eof());
|
||||||
(!aSection.Name().IsEqual((Standard_CString)SHAPESECTION_POS));
|
|
||||||
|
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
|
aDocumentPos = theIStream.tellg(); // position of root label
|
||||||
|
|
||||||
BinLDrivers_VectorOfDocumentSection::Iterator anIterS (mySections);
|
BinLDrivers_VectorOfDocumentSection::Iterator anIterS (mySections);
|
||||||
@ -336,7 +343,8 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
|
|||||||
// Read attributes:
|
// Read attributes:
|
||||||
theIS >> myPAtt;
|
theIS >> myPAtt;
|
||||||
while (theIS && myPAtt.TypeId() > 0 && // not an end marker ?
|
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
|
// get a driver according to TypeId
|
||||||
Handle(BinMDF_ADriver) aDriver = myDrivers->GetDriver (myPAtt.TypeId());
|
Handle(BinMDF_ADriver) aDriver = myDrivers->GetDriver (myPAtt.TypeId());
|
||||||
if (!aDriver.IsNull()) {
|
if (!aDriver.IsNull()) {
|
||||||
@ -386,7 +394,7 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
|
|||||||
#if DO_INVERSE
|
#if DO_INVERSE
|
||||||
aTag = InverseInt (aTag);
|
aTag = InverseInt (aTag);
|
||||||
#endif
|
#endif
|
||||||
while (theIS && aTag >= 0) { // not an end marker ?
|
while (theIS && aTag >= 0 && !theIS.eof()) { // not an end marker ?
|
||||||
// create sub-label
|
// create sub-label
|
||||||
TDF_Label aLab = theLabel.FindChild (aTag, Standard_True);
|
TDF_Label aLab = theLabel.FindChild (aTag, Standard_True);
|
||||||
|
|
||||||
|
12
tests/bugs/caf/bug27667
Normal file
12
tests/bugs/caf/bug27667
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
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 }
|
Loading…
x
Reference in New Issue
Block a user