Commit 469be374 authored by Robert Ricci's avatar Robert Ricci

Fix a bug in the reorderLinks() function

Because it's operating on char*s, the STL list remove() function
doesn't work; it needs to do a strcmp, not a simple comparison. So, hand-write
the loop to do this.

Also add a santity check to produce a fatal error rather than allowing this
function to go into an infinite loop.
parent 8700c093
......@@ -687,8 +687,27 @@ annotate_rspec_v2::reorderLinks (list<const char*>* links)
prev = this->find_next_link_in_path(prev, links);
string* link
= new string(XStr(prev->getAttribute(XStr("component_id").x())).c());
// Remove this link from the list - would rather use links->remove(), but
// it doesn't seem to be able to compare strings
list<const char*>::iterator it;
bool found = false;
for (it = links->begin(); it != links->end(); it++) {
if (!strcmp(link->c_str(),*it)) {
found = true;
if (found) {
} else {
// Sanity check
cerr << "Error annotating link: couldn't find link (" <<
link->c_str() << ")" << endl;
return ordered;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment