The adata pointer was not properly being set to
0 before being used. In addition notice malloc
failure and hard exit. If we have no memory on
startup something terrible has gone wrong and
we were going to crash shortly here anyways.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
*/
if (adata == NULL) {
/* XXX Free on shutdown. */
- adata = malloc(CMSG_SPACE(sizeof(struct in6_pktinfo)));
+ adata = calloc(1, CMSG_SPACE(sizeof(struct in6_pktinfo)));
- if (adata == NULL)
+ if (adata == NULL) {
zlog_err(
"rtadv_send_packet: can't malloc control data");
+ exit(-1);
+ }
}
/* Logging of packet. */