diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 9cfec0fe2f..c013160d95 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1644,8 +1644,21 @@ DEFPY(bgp_community_alias, bgp_community_alias_cmd, struct community_alias ca2; struct community_alias *lookup_community; struct community_alias *lookup_alias; + struct community *comm; + struct lcommunity *lcomm; + uint8_t invalid = 0; - if (!community_str2com(community) && !lcommunity_str2com(community)) { + comm = community_str2com(community); + if (!comm) + invalid++; + community_free(&comm); + + lcomm = lcommunity_str2com(community); + if (!lcomm) + invalid++; + lcommunity_free(&lcomm); + + if (invalid > 1) { vty_out(vty, "Invalid community format\n"); return CMD_WARNING; }