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);
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to