fixed off-by-one read error in xml-parser, and removed some unnecessary casts in the unit test

This commit is contained in:
Arvid Norberg 2012-02-18 09:54:49 +00:00
parent 5a23d04143
commit 67b12dfb90
2 changed files with 3 additions and 3 deletions

View File

@ -65,7 +65,7 @@ namespace libtorrent
char const* val_start = 0;
int token;
// look for tag start
for(; *p != '<' && p != end; ++p);
for(; p != end && *p != '<'; ++p);
if (p != start)
{

View File

@ -1351,7 +1351,7 @@ int test_main()
parse_state xml_s;
xml_s.reset("urn:schemas-upnp-org:service:WANIPConnection:1");
xml_parse((char*)upnp_xml, (char*)upnp_xml + sizeof(upnp_xml)
xml_parse(upnp_xml, upnp_xml + sizeof(upnp_xml)
, boost::bind(&find_control_url, _1, _2, boost::ref(xml_s)));
std::cerr << "namespace " << xml_s.service_type << std::endl;
@ -1363,7 +1363,7 @@ int test_main()
TEST_CHECK(xml_s.model == "D-Link Router");
xml_s.reset("urn:schemas-upnp-org:service:WANPPPConnection:1");
xml_parse((char*)upnp_xml2, (char*)upnp_xml2 + sizeof(upnp_xml2)
xml_parse(upnp_xml2, upnp_xml2 + sizeof(upnp_xml2)
, boost::bind(&find_control_url, _1, _2, boost::ref(xml_s)));
std::cerr << "namespace " << xml_s.service_type << std::endl;