7045172 serious memory leak in top
authorRich Burridge <rich.burridge@oracle.com>
Wed, 31 Aug 2011 13:46:18 -0700
changeset 506 82fe65b0edf8
parent 505 310ffa9f1045
child 507 0e8b0812f44f
7045172 serious memory leak in top
components/top/patches/03.sunos5.patch
--- a/components/top/patches/03.sunos5.patch	Wed Aug 31 12:42:31 2011 -0700
+++ b/components/top/patches/03.sunos5.patch	Wed Aug 31 13:46:18 2011 -0700
@@ -1,17 +1,42 @@
---- top-3.8beta1/machine/m_sunos5.c.orig	Fri Jun 17 05:40:25 2011
-+++ top-3.8beta1/machine/m_sunos5.c	Fri Jun 17 05:48:17 2011
-@@ -2064,7 +2064,13 @@
- 
- 	    /* read the whole file */
- 	    p = malloc(st.st_size);
--	    (void)pread(fd, p, st.st_size, 0);
-+	    if (pread(fd, p, st.st_size, 0) == -1)
-+	    {
-+		(void) close(fd);
-+		op->fd_psinfo = -1;
-+		free(p);
-+		continue;
-+	    }	
- 
- 	    /* cache the file descriptor if we can */
- 	    if (fd < maxfiles)
+*** top-3.8beta1/machine/m_sunos5.c.orig	Wed Aug 31 05:23:52 2011
+--- top-3.8beta1/machine/m_sunos5.c	Wed Aug 31 05:25:25 2011
+***************
+*** 2064,2070 ****
+  
+  	    /* read the whole file */
+  	    p = malloc(st.st_size);
+! 	    (void)pread(fd, p, st.st_size, 0);
+  
+  	    /* cache the file descriptor if we can */
+  	    if (fd < maxfiles)
+--- 2064,2076 ----
+  
+  	    /* read the whole file */
+  	    p = malloc(st.st_size);
+! 	    if (pread(fd, p, st.st_size, 0) == -1)
+! 	    {
+! 		(void) close(fd);
+! 		op->fd_psinfo = -1;
+! 		free(p);
+! 		continue;
+! 	    }
+  
+  	    /* cache the file descriptor if we can */
+  	    if (fd < maxfiles)
+***************
+*** 2148,2154 ****
+  		op->oldtime = TIMESPEC_TO_DOUBLE(lwpp->pr_time);
+  		op->seen = 1;
+  	    }
+! 	    free(p);
+  	}
+  #endif
+  
+--- 2154,2160 ----
+  		op->oldtime = TIMESPEC_TO_DOUBLE(lwpp->pr_time);
+  		op->seen = 1;
+  	    }
+! 	    free(prp);
+  	}
+  #endif
+