lib: fix the right value is returned for fail cases

Currently `bfd_get_peer_info` should return invalid sp->family
and dp->family during fail cases.

Before this fix, in those fail cases `bfd_get_peer_info` maybe
return valid sp->family and dp->family.

This fix ensures all fail cases return invalid sp->family and
dp->family for outside callers.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
This commit is contained in:
anlan_cs 2022-01-12 07:53:25 -05:00
parent 4d33086cad
commit 10f02a2ac9

View file

@ -171,6 +171,12 @@ static struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp,
return ifp;
stream_failure:
/*
* Clean dp and sp because caller
* will immediately check them valid or not
*/
memset(dp, 0, sizeof(*dp));
memset(sp, 0, sizeof(*sp));
return NULL;
}