-/* $OpenBSD: rde_community.c,v 1.15 2024/01/24 14:51:12 claudio Exp $ */
+/* $OpenBSD: rde_community.c,v 1.16 2024/09/10 08:53:20 claudio Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
memset(to, 0, sizeof(*to));
/* ignore from->size and allocate the perfect amount */
- to->size = from->size;
+ to->size = from->nentries;
to->nentries = from->nentries;
to->flags = from->flags;
+ if (to->nentries == 0)
+ return;
+
if ((to->communities = reallocarray(NULL, to->size,
sizeof(struct community))) == NULL)
fatal(__func__);
memcpy(to->communities, from->communities,
to->nentries * sizeof(struct community));
- memset(to->communities + to->nentries, 0, sizeof(struct community) *
- (to->size - to->nentries));
}
/*