XPath: Out-of-bounds xpath_node_set access is now undefined
git-svn-id: http://pugixml.googlecode.com/svn/trunk@581 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
df42996eab
commit
f4cb6eb737
@ -2215,7 +2215,7 @@ namespace pugi
|
|||||||
* \param index - requested index
|
* \param index - requested index
|
||||||
* \return element
|
* \return element
|
||||||
*/
|
*/
|
||||||
xpath_node operator[](size_t index) const;
|
const xpath_node& operator[](size_t index) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get begin constant iterator for collection
|
* Get begin constant iterator for collection
|
||||||
|
|||||||
@ -792,9 +792,10 @@ namespace pugi
|
|||||||
return size() == 0;
|
return size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
xpath_node xpath_node_set::operator[](size_t index) const
|
const xpath_node& xpath_node_set::operator[](size_t index) const
|
||||||
{
|
{
|
||||||
return (index >= size()) ? xpath_node() : m_begin[index];
|
assert(index < size());
|
||||||
|
return m_begin[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
xpath_node_set::iterator xpath_node_set::mut_begin()
|
xpath_node_set::iterator xpath_node_set::mut_begin()
|
||||||
|
|||||||
@ -87,7 +87,6 @@ inline void xpath_api_node_accessors_helper(const xpath_node_set& set)
|
|||||||
CHECK(!set.empty());
|
CHECK(!set.empty());
|
||||||
CHECK_STRING(set[0].node().name(), STR("foo"));
|
CHECK_STRING(set[0].node().name(), STR("foo"));
|
||||||
CHECK_STRING(set[1].node().name(), STR("foo"));
|
CHECK_STRING(set[1].node().name(), STR("foo"));
|
||||||
CHECK(!set[2]);
|
|
||||||
CHECK(set.first() == set[0]);
|
CHECK(set.first() == set[0]);
|
||||||
CHECK(set.begin() + 2 == set.end());
|
CHECK(set.begin() + 2 == set.end());
|
||||||
CHECK(set.begin()[0] == set[0] && set.begin()[1] == set[1]);
|
CHECK(set.begin()[0] == set[0] && set.begin()[1] == set[1]);
|
||||||
@ -99,7 +98,6 @@ TEST_XML(xpath_api_nodeset_accessors, "<node><foo/><foo/></node>")
|
|||||||
CHECK(null.size() == 0);
|
CHECK(null.size() == 0);
|
||||||
CHECK(null.type() == xpath_node_set::type_unsorted);
|
CHECK(null.type() == xpath_node_set::type_unsorted);
|
||||||
CHECK(null.empty());
|
CHECK(null.empty());
|
||||||
CHECK(!null[0]);
|
|
||||||
CHECK(!null.first());
|
CHECK(!null.first());
|
||||||
CHECK(null.begin() == null.end());
|
CHECK(null.begin() == null.end());
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user