From: Philip Homburg Date: Thu, 16 Feb 2006 14:13:36 +0000 (+0000) Subject: Fixed two memory leaks. X-Git-Tag: v3.1.2a~356 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/verify-sign/verify.pl?a=commitdiff_plain;h=df92754d671ef58ab926760afe4da8a4b2f0cd51;p=minix.git Fixed two memory leaks. --- diff --git a/servers/inet/generic/arp.c b/servers/inet/generic/arp.c index 84ea087b0..536d58ef0 100644 --- a/servers/inet/generic/arp.c +++ b/servers/inet/generic/arp.c @@ -1340,7 +1340,12 @@ PRIVATE void arp_bufcheck() for (i= 0, arp_port= arp_port_table; iap_reqlist; pack; + for (pack= arp_port->ap_reclist; pack; + pack= pack->acc_ext_link) + { + bf_check_acc(pack); + } + for (pack= arp_port->ap_sendlist; pack; pack= pack->acc_ext_link) { bf_check_acc(pack); diff --git a/servers/inet/generic/eth.c b/servers/inet/generic/eth.c index 363aea6e4..8a118b0a6 100644 --- a/servers/inet/generic/eth.c +++ b/servers/inet/generic/eth.c @@ -335,9 +335,6 @@ ioreq_t req; return NW_OK; } - acc= bf_memreq(sizeof(nwio_ethstat_t)); - compare (bf_bufsize(acc), ==, sizeof(*ethstat)); - if (!(eth_port->etp_flags & EPF_GOT_ADDR)) { printf( @@ -349,6 +346,9 @@ ioreq_t req; return NW_SUSPEND; } + acc= bf_memreq(sizeof(nwio_ethstat_t)); + compare (bf_bufsize(acc), ==, sizeof(*ethstat)); + ethstat= (nwio_ethstat_t *)ptr2acc_data(acc); ethstat->nwes_addr= eth_port->etp_ethaddr; diff --git a/servers/inet/generic/tcp.c b/servers/inet/generic/tcp.c index c623674b2..f7cee644f 100644 --- a/servers/inet/generic/tcp.c +++ b/servers/inet/generic/tcp.c @@ -2269,12 +2269,14 @@ tcp_fd_t *tcp_fd; sizeof(*cookiep), TRUE); if (!data) return EFAULT; + data= bf_packIffLess(data, sizeof(*cookiep)); cookiep= (tcp_cookie_t *)ptr2acc_data(data); dst_nr= cookiep->tc_ref; if (dst_nr < 0 || dst_nr >= TCP_FD_NR) { + bf_afree(data); data= NULL; printf("tcp_acceptto: bad fd %d\n", dst_nr); tcp_reply_ioctl(tcp_fd, EINVAL); return NW_OK; @@ -2285,6 +2287,7 @@ tcp_fd_t *tcp_fd; dst_fd->tf_conn != NULL || !(dst_fd->tf_flags & TFF_COOKIE)) { + bf_afree(data); data= NULL; printf("tcp_acceptto: bad flags 0x%x or conn %p for fd %d\n", dst_fd->tf_flags, dst_fd->tf_conn, dst_nr); tcp_reply_ioctl(tcp_fd, EINVAL); @@ -2292,10 +2295,13 @@ tcp_fd_t *tcp_fd; } if (memcmp(cookiep, &dst_fd->tf_cookie, sizeof(*cookiep)) != 0) { + bf_afree(data); data= NULL; printf("tcp_acceptto: bad cookie\n"); return NW_OK; } + bf_afree(data); data= NULL; + /* Move connection */ tcp_fd->tf_listenq[i]= NULL; tcp_conn->tc_fd= dst_fd;