Fixed a bug in parse_xml(). It failed to check if the given input stream was

valid before trying to parse it.
This commit is contained in:
Davis King 2015-08-15 11:01:47 -04:00
parent ecdfdea677
commit c78b9fed34
2 changed files with 12 additions and 5 deletions

View File

@ -1412,6 +1412,8 @@ namespace dlib
error_handler& eh
)
{
if (!in)
throw xml_parse_error("Unexpected end of file during xml parsing.");
xml_parser parser;
parser.add_document_handler(dh);
parser.add_error_handler(eh);
@ -1424,6 +1426,8 @@ namespace dlib
document_handler& dh
)
{
if (!in)
throw xml_parse_error("Unexpected end of file during xml parsing.");
xml_parser parser;
parser.add_document_handler(dh);
parser.add_error_handler(eh);
@ -1435,6 +1439,8 @@ namespace dlib
error_handler& eh
)
{
if (!in)
throw xml_parse_error("Unexpected end of file during xml parsing.");
xml_parser parser;
parser.add_error_handler(eh);
parser.parse(in);
@ -1445,6 +1451,8 @@ namespace dlib
document_handler& dh
)
{
if (!in)
throw xml_parse_error("Unexpected end of file during xml parsing.");
xml_parser parser;
parser.add_document_handler(dh);
impl::default_xml_error_handler eh;

View File

@ -223,7 +223,7 @@ namespace dlib
supplied error_handler and document_handler.
throws
- xml_parse_error
Thrown if there is a problem opening the input file.
Thrown if there is a problem parsing the input file.
!*/
void parse_xml (
@ -237,7 +237,7 @@ namespace dlib
supplied error_handler and document_handler.
throws
- xml_parse_error
Thrown if there is a problem opening the input file.
Thrown if there is a problem parsing the input file.
!*/
void parse_xml (
@ -250,7 +250,7 @@ namespace dlib
supplied error_handler.
throws
- xml_parse_error
Thrown if there is a problem opening the input file.
Thrown if there is a problem parsing the input file.
!*/
void parse_xml (
@ -265,8 +265,7 @@ namespace dlib
if a fatal parsing error is encountered.
throws
- xml_parse_error
Thrown if a fatal parsing error is encountered or if there is a problem
opening the input file.
Thrown if there is a problem parsing the input file.
!*/
// ----------------------------------------------------------------------------------------