mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0027454: Application hangs while opening a non-OCAF XML file
1) Add protection against accessing null pointer in PCDM_ReadWriter::FileFormat. 2) In LDOM_XmlReader::ReadRecord, take into account that the character '>' can have no special meaning (e.g., in a text), and we must read the data behind this character to complete the current tag reading. This treatment concerns the mode of work when myTagPerStep is true. 3) Create a test case of reading of XML file not related to OCAF document. Test case was added.
This commit is contained in:
@@ -107,6 +107,8 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
|
||||
}
|
||||
else if (myTagPerStep && aHasRead)
|
||||
{
|
||||
// in myTagPerStep mode, we should parse the buffer to the end before
|
||||
// getting more characters from the stream.
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -225,6 +227,7 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
|
||||
aState = STATE_TEXT;
|
||||
aStartData = myPtr;
|
||||
myPtr = myEndPtr;
|
||||
aHasRead = Standard_False;
|
||||
} // end of checking in STATE_WAITING
|
||||
continue;
|
||||
|
||||
@@ -244,6 +247,7 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
|
||||
return XML_HEADER;
|
||||
}
|
||||
myPtr = myEndPtr - 1;
|
||||
aHasRead = Standard_False;
|
||||
continue;
|
||||
|
||||
// Checking the characters in STATE_DOCTYPE, seek for "]>" sequence
|
||||
@@ -264,6 +268,7 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
|
||||
}
|
||||
}
|
||||
myPtr = myEndPtr - 1;
|
||||
aHasRead = Standard_False;
|
||||
continue;
|
||||
|
||||
state_doctype_markup:
|
||||
@@ -282,6 +287,7 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
|
||||
return XML_DOCTYPE;
|
||||
}
|
||||
myPtr = myEndPtr - 1;
|
||||
aHasRead = Standard_False;
|
||||
continue;
|
||||
|
||||
// Checking the characters in STATE_COMMENT, seek for "-->" sequence
|
||||
@@ -303,6 +309,7 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
|
||||
}
|
||||
}
|
||||
myPtr = myEndPtr - 2;
|
||||
aHasRead = Standard_False;
|
||||
continue;
|
||||
|
||||
// Checking the characters in STATE_TEXT, seek for "<"
|
||||
@@ -316,6 +323,7 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
|
||||
return XML_TEXT;
|
||||
}
|
||||
myPtr = myEndPtr;
|
||||
aHasRead = Standard_False;
|
||||
continue;
|
||||
|
||||
// Checking the characters in STATE_CDATA, seek for "]]"
|
||||
@@ -334,6 +342,7 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
|
||||
return XML_CDATA;
|
||||
}
|
||||
myPtr = myEndPtr - 1;
|
||||
aHasRead = Standard_False;
|
||||
continue;
|
||||
|
||||
// Checking the characters in STATE_ELEMENT, seek the end of TagName
|
||||
@@ -489,8 +498,11 @@ attr_name:
|
||||
myPtr = aPtr + 1;
|
||||
aStartData = NULL;
|
||||
aState = STATE_ATTRIBUTE_NAME;
|
||||
} else
|
||||
}
|
||||
else {
|
||||
myPtr = myEndPtr;
|
||||
aHasRead = Standard_False;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Checking the characters in STATE_ELEMENT_END, seek for ">"
|
||||
@@ -504,6 +516,7 @@ attr_name:
|
||||
return XML_END_ELEMENT;
|
||||
}
|
||||
myPtr = myEndPtr;
|
||||
aHasRead = Standard_False;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user