From: Danny Mayer Date: Thu, 16 Mar 2006 22:55:20 +0000 (-0500) Subject: [Bug 479] Fix Memory Leak X-Git-Tag: NTP_4_2_1P10_RC~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af3aa3a3d01e36555d2e9e38e08a071ce1b67ff1;p=thirdparty%2Fntp.git [Bug 479] Fix Memory Leak bk: 4419ecd8QlzVUzleMQyTRSotCW8iPw --- diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 1fb107a6a..9614ddeb5 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -298,7 +298,7 @@ init_io(void) any6_interface = NULL; #ifdef REFCLOCK - refio = 0; + refio = NULL; #endif #if defined(HAVE_SIGNALED_IO) @@ -2120,7 +2120,10 @@ read_network_packet(SOCKET fd, struct interface *itf, l_fp ts) { char buf[RX_BUFF_SIZE]; struct sockaddr_storage from; - fromlen = sizeof from; + if (rb != NULL) + freerecvbuf(rb); + + fromlen = sizeof(from); buflen = recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr*)&from, &fromlen); #ifdef DEBUG @@ -2233,12 +2236,6 @@ input_handler( n = select(maxactivefd+1, &fds, (fd_set *)0, (fd_set *)0, &tvzero); -#ifdef REFCLOCK - /* - * Check out the reference clocks first, if any - */ - - /* * If there are no packets waiting just return */ @@ -2267,11 +2264,16 @@ input_handler( ++handler_pkts; - if (refio != 0) +#ifdef REFCLOCK + /* + * Check out the reference clocks first, if any + */ + + if (refio != NULL) { register struct refclockio *rp; - for (rp = refio; rp != 0; rp = rp->next) + for (rp = refio; rp != NULL; rp = rp->next) { fd = rp->fd; @@ -2745,14 +2747,14 @@ io_closeclock( { register struct refclockio *rp; - for (rp = refio; rp != 0; rp = rp->next) + for (rp = refio; rp != NULL; rp = rp->next) if (rp->next == rio) { rp->next = rio->next; break; } - if (rp == 0) + if (rp == NULL) return; }