Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nil pointer dereference panic in Find() if module by prefix is not found #252

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkg/yang/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -1322,11 +1322,17 @@ func (e *Entry) Find(name string) *Entry {
e = e.Parent
}
if prefix, _ := getPrefix(parts[0]); prefix != "" {
m := module(FindModuleByPrefix(contextNode, prefix))
if m == nil {
mod := FindModuleByPrefix(contextNode, prefix)
if mod == nil {
e.addError(fmt.Errorf("cannot find module giving prefix %q within context entry %q", prefix, e.Path()))
return nil
}
m := module(mod)
if m == nil {
e.addError(fmt.Errorf("cannot find which module %q belongs to within context entry %q",
mod.NName(), e.Path()))
return nil
}
if m != e.Node.(*Module) {
e = ToEntry(m)
}
Expand Down
Loading