Skip to content

Commit 332de49

Browse files
mergify[bot]alsora
andauthored
extend termination condition to avoid infinite loop if package.xml is not found (#220) (#243)
(cherry picked from commit 840db44) Co-authored-by: Alberto Soragna <[email protected]> Signed-off-by: Alberto Soragna <[email protected]>
1 parent 7cfba76 commit 332de49

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pluginlib/include/pluginlib/class_loader_imp.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,13 @@ ClassLoader<T>::getPackageFromPluginXMLFilePath(const std::string & plugin_xml_f
597597
return extractPackageNameFromPackageXML(package_file_path);
598598
}
599599

600-
// Recursive case - hop one folder up
600+
// Recursive case - hop one folder up and store current parent
601+
// parent_path() returns the current path if we reached the root.
602+
p = parent;
601603
parent = parent.parent_path();
602604

603605
// Base case - reached root and cannot find what we're looking for
604-
if (parent.string().empty()) {
606+
if (parent.string().empty() || (p == parent)) {
605607
return "";
606608
}
607609
}

0 commit comments

Comments
 (0)