0
0
mirror of https://github.com/zeux/pugixml.git synced 2025-01-14 01:47:55 +08:00

Merge branch 'master' of https://github.com/mloy/pugixml into mloy-master

This commit is contained in:
Arseny Kapoulkine 2015-03-05 10:09:54 -08:00
commit 7ae7344256
2 changed files with 21 additions and 1 deletions

View File

@ -4316,7 +4316,12 @@ PUGI__NS_BEGIN
PUGI__FN xml_parse_result load_buffer_impl(xml_document_struct* doc, xml_node_struct* root, void* contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own, char_t** out_buffer)
{
// check input buffer
assert(contents || size == 0);
if ((contents==NULL) && (size!=0)) {
xml_parse_result result;
result.status = status_no_document_element;
return result;
}
// get actual encoding
xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size);

View File

@ -863,10 +863,25 @@ TEST(parse_declaration_error)
TEST(parse_empty)
{
xml_document doc;
CHECK(doc.load_string(STR("")).status == status_no_document_element && !doc.first_child());
CHECK(doc.load_string(STR(""), parse_fragment) && !doc.first_child());
}
TEST(parse_load_buffer_null)
{
xml_document doc;
CHECK(doc.load_buffer(0, 12).status == status_no_document_element && !doc.first_child());
}
TEST(parse_load_buffer_empty)
{
xml_document doc;
CHECK(doc.load_buffer("foo", 0).status == status_no_document_element);
}
TEST(parse_out_of_memory)
{
test_runner::_memory_fail_threshold = 256;