]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 479] Fix Memory Leak
authorDanny Mayer <mayer@ntp.org>
Thu, 16 Mar 2006 22:55:20 +0000 (17:55 -0500)
committerDanny Mayer <mayer@ntp.org>
Thu, 16 Mar 2006 22:55:20 +0000 (17:55 -0500)
bk: 4419ecd8QlzVUzleMQyTRSotCW8iPw

ntpd/ntp_io.c

index 1fb107a6a759065d903cbd8efb81d537b546bf55..9614ddeb56e846a1c20987a3a5f4b9a46c7a0b8f 100644 (file)
@@ -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;
        }