mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-29 07:49:14 +01:00
Add nil check in CheckRoutes to prevent potential panic
This commit is contained in:
@@ -370,6 +370,10 @@ func (d *Status) RemovePeerStateRoute(peer string, route string) error {
|
|||||||
// CheckRoutes checks if the source and destination addresses are within the same route
|
// CheckRoutes checks if the source and destination addresses are within the same route
|
||||||
// and returns the resource ID of the route that contains the addresses
|
// and returns the resource ID of the route that contains the addresses
|
||||||
func (d *Status) CheckRoutes(src, dst netip.Addr, direction nftypes.Direction) (srcResId string, dstResId string) {
|
func (d *Status) CheckRoutes(src, dst netip.Addr, direction nftypes.Direction) (srcResId string, dstResId string) {
|
||||||
|
if d == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
d.mux.Lock()
|
d.mux.Lock()
|
||||||
d.resIdMux.Lock()
|
d.resIdMux.Lock()
|
||||||
defer d.resIdMux.Unlock()
|
defer d.resIdMux.Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user