From 5dd7070f73846b689e54b5e3cc4e8a8a7d797b1e Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 7 Jan 2020 00:51:35 -0500 Subject: [PATCH] bgpd: avoid memcmp(NULL, NULL) Undefined behavior Signed-off-by: Quentin Young --- bgpd/bgp_attr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index fe7a80ccf2..bdac2a8dcc 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -152,8 +152,9 @@ static bool cluster_hash_cmp(const void *p1, const void *p2) const struct cluster_list *cluster2 = p2; return (cluster1->length == cluster2->length - && memcmp(cluster1->list, cluster2->list, cluster1->length) - == 0); + && (cluster1->list == cluster2->list + || memcmp(cluster1->list, cluster2->list, cluster1->length) + == 0)); } static void cluster_free(struct cluster_list *cluster) -- 2.39.5