openconfig / goyang

YANG parser and compiler to produce Go language objects
Apache License 2.0
221 stars 86 forks source link

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

Closed sengleung closed 1 year ago

sengleung commented 1 year ago

Previously, if FindModuleByPrefix() returns nil in Find(), it would continue to call module() with nil, resulting in a nil pointer dereference panic when trying to call ParentNode() from RootNode(). The fix is to return an error if FindModuleByPrefix() returns nil.

Fixes #251

coveralls commented 1 year ago

Coverage Status

coverage: 83.677% (-0.08%) from 83.76% when pulling c1b2136ad52d1e6ca923fa4843463198e3276e1d on sengleung:find-panic-fix into 944052f4c47385554f2fb0f46ca4ecfbf446450c on openconfig:master.

wenovus commented 1 year ago

Thanks for the fix