From owner-svn-src-all@FreeBSD.ORG Thu Jun 18 15:27:28 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E178106568B; Thu, 18 Jun 2009 15:27:28 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0BCBC8FC23; Thu, 18 Jun 2009 15:27:28 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5IFRRAL015431; Thu, 18 Jun 2009 15:27:27 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5IFRR1B015429; Thu, 18 Jun 2009 15:27:27 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <200906181527.n5IFRR1B015429@svn.freebsd.org> From: Ed Maste Date: Thu, 18 Jun 2009 15:27:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194444 - stable/6/usr.bin/gcore X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jun 2009 15:27:28 -0000 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);