mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-26 21:04:25 +08:00
load_buffer_impl always checks if buffer is valid pointer and size > 0
added some tests to force invalid buffer and size = 0
This commit is contained in:
parent
21cff3bca2
commit
837ced350c
@ -4292,7 +4292,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);
|
||||
|
@ -865,6 +865,8 @@ TEST(parse_empty)
|
||||
xml_document doc;
|
||||
CHECK(doc.load(STR("")).status == status_no_document_element && !doc.first_child());
|
||||
CHECK(doc.load(STR(""), parse_fragment) && !doc.first_child());
|
||||
CHECK(doc.load_buffer(NULL, 12).status == status_no_document_element);
|
||||
CHECK(doc.load_buffer("foo", 0).status == status_no_document_element);
|
||||
}
|
||||
|
||||
TEST(parse_out_of_memory)
|
||||
|
Loading…
x
Reference in New Issue
Block a user