Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jun 2009 15:27:27 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org
Subject:   svn commit: r194444 - stable/6/usr.bin/gcore
Message-ID:  <200906181527.n5IFRR1B015429@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Thu Jun 18 15:27:27 2009
New Revision: 194444
URL: http://svn.freebsd.org/changeset/base/194444

Log:
  MFC r168595 and r180603:
  
    Eliminate memory leak from an accidental malloc().  Use %zd for size_t.

Modified:
  stable/6/usr.bin/gcore/   (props changed)
  stable/6/usr.bin/gcore/elfcore.c

Modified: stable/6/usr.bin/gcore/elfcore.c
==============================================================================
--- stable/6/usr.bin/gcore/elfcore.c	Thu Jun 18 15:08:37 2009	(r194443)
+++ stable/6/usr.bin/gcore/elfcore.c	Thu Jun 18 15:27:27 2009	(r194444)
@@ -130,7 +130,6 @@ elf_coredump(int efd __unused, int fd, p
 	 * Allocate memory for building the header, fill it up,
 	 * and write it out.
 	 */
-	hdr = malloc(hdrsize);
 	if ((hdr = malloc(hdrsize)) == NULL)
 		errx(1, "out of memory");
 	elf_corehdr(fd, pid, map, seginfo.count, hdr, hdrsize);
@@ -159,7 +158,7 @@ elf_coredump(int efd __unused, int fd, p
 				err(1, "read from %s", memname);
 			if ((size_t)ngot < nwant)
 				errx(1, "short read from %s:"
-				    " wanted %d, got %d", memname,
+				    " wanted %zd, got %zd", memname,
 				    nwant, ngot);
 			ngot = write(fd, buf, nwant);
 			if (ngot == -1)
@@ -415,7 +414,7 @@ readhdrinfo(pid_t pid, prstatus_t *statu
 	if ((n = read(fd, &status->pr_reg, sizeof status->pr_reg)) == -1)
 		err(1, "read error from %s", name);
 	if ((size_t)n < sizeof(status->pr_reg))
-		errx(1, "short read from %s: wanted %u, got %d", name,
+		errx(1, "short read from %s: wanted %zd, got %d", name,
 		    sizeof status->pr_reg, n);
 	close(fd);
 
@@ -426,7 +425,7 @@ readhdrinfo(pid_t pid, prstatus_t *statu
 	if ((n = read(fd, fpregset, sizeof *fpregset)) == -1)
 		err(1, "read error from %s", name);
 	if ((size_t)n < sizeof(*fpregset))
-		errx(1, "short read from %s: wanted %u, got %d", name,
+		errx(1, "short read from %s: wanted %zd, got %d", name,
 		    sizeof *fpregset, n);
 	close(fd);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906181527.n5IFRR1B015429>