Fix segfault on `ls module:*`
This code was calling a wrong libyang function; instead of requesting "a
model named foo", it was asking for "a model named foo with no
revision", and happily segfaulting.
Depends-on: https://gerrit.cesnet.cz/c/CzechLight/dependencies/+/6734
Change-Id: I6c4496d6c1102d6854b0295e23b624f306481134
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 4209b2a..26ef38d 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -330,7 +330,7 @@
std::string topLevelModule;
if (path.type() == typeid(module_)) {
- nodeCollections.emplace_back(m_context.getModule(boost::get<module_>(path).m_name)->childInstantiables());
+ nodeCollections.emplace_back(m_context.getModuleLatest(boost::get<module_>(path).m_name)->childInstantiables());
} else {
auto schemaPath = anyPathToSchemaPath(path);
if (schemaPath.m_nodes.empty()) {
diff --git a/tests/yang.cpp b/tests/yang.cpp
index f56a27b..320e218 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -1052,6 +1052,10 @@
{boost::none, "/second-schema:bla/bla2"}
};
}
+ SECTION("schema-with-revision")
+ {
+ module = "schema-with-revision";
+ }
REQUIRE(ys.availableNodes(module_{module}, Recursion::NonRecursive) == expectedNonRecursive);
REQUIRE(ys.availableNodes(module_{module}, Recursion::Recursive) == expectedRecursive);