Compare commits

...

1 Commits

Author SHA1 Message Date
Chaitanya Godavarthi
7a634d80ed APC: Fix memory leaks
Fixed memory leaks in apc and interapcomm modules.

Signed-off-by: Rick Sommerville <rick.sommerville@netexperience.com>
2021-04-30 12:32:38 -04:00
6 changed files with 15 additions and 5 deletions

View File

@@ -30,4 +30,9 @@ static inline timer * tm_new_set( void (*hook)(struct _timer *), void *data, uns
return t;
}
static inline void tm_free(timer *t)
{
free(t);
}
#endif

View File

@@ -26,7 +26,8 @@ static void apc_dump( struct proto * P )
static struct proto * apc_init(struct proto_config * c)
{
struct proto * P = mb_allocz(sizeof(struct apc_proto));
printf("apc_init\n");
P->cf = c;
P->debug = c->debug;
P->mrtdump = c->mrtdump;

View File

@@ -103,6 +103,7 @@ void apc_send_hello(struct apc_iface * ifa, int kind )
struct apc_hello2_packet ps;
unsigned int length, report = 0;
struct apc_spec ApcSpec;
char dst_ip[16];
if (WaitingToReelect )
return;
@@ -202,8 +203,7 @@ void apc_send_hello(struct apc_iface * ifa, int kind )
length += i * sizeof(u32);
printf("HELLO packet sent via %s\n", ifa->ifname );
char *dst_ip = malloc(16);
printf("HELLO packet sent via %s\n", ifa->ifname );
memset(dst_ip, 0, 16);
if ((get_current_ip(dst_ip, IAC_IFACE)) < 0) {
printf("Error: Cannot get IP for %s", IAC_IFACE);

View File

@@ -36,7 +36,7 @@ reset_lists(struct apc_proto *p, struct apc_neighbor *n)
struct apc_neighbor * apc_neighbor_new(struct apc_iface * ifa)
{
struct apc_neighbor * n = mb_allocz(sizeof(struct apc_neighbor));
printf("apc_new_neighbor\n");
n->ifa = ifa;
add_tail(&ifa->neigh_list, NODE n);
n->adj = 0;
@@ -58,6 +58,8 @@ static void apc_neigh_down(struct apc_neighbor * n)
rem_node(NODE n);
printf("Neighbor %x on %s removed", n->rid, ifa->ifname );
tm_free(n->inactim);
mb_free(n);
}
/**

View File

@@ -26,6 +26,7 @@ static void receive_data_uloop(struct uloop_fd *fd, unsigned int events)
printf("recvfrom() failed");
ra.cb(recv_data, recv_data_len);
free(recv_data);
}
@@ -41,6 +42,7 @@ static void receive_data(struct ev_loop *ev, ev_io *io, int event)
printf("recvfrom() failed");
ra.cb(recv_data, recv_data_len);
free(recv_data);
}

View File

@@ -130,6 +130,7 @@ static int rx_msg(struct nl_msg *msg, void* arg)
struct nlattr *attr[GENL_UCC_ATTR_MAX+1];
struct voip_session *data;
char dst_ip[16];
genlmsg_parse(nlmsg_hdr(msg), 0, attr,
GENL_UCC_ATTR_MAX, genl_ucc_policy);
@@ -140,7 +141,6 @@ static int rx_msg(struct nl_msg *msg, void* arg)
return NL_OK;
}
char *dst_ip = malloc(16);
memset(dst_ip, 0, 16);
if((get_current_ip(dst_ip, IAC_IFACE)) < 0) {
LOGI("Error: Cannot get IP for %s", IAC_IFACE);