Mercurial > hg > toybox
changeset 1465:2148d1502264 draft
Fix more memory leaks reported by Ashwini Sharma.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 08 Sep 2014 08:51:45 -0500 |
parents | 836ff051a071 |
children | aa0ae038e275 |
files | toys/posix/cpio.c |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/posix/cpio.c Mon Sep 08 08:40:06 2014 -0500 +++ b/toys/posix/cpio.c Mon Sep 08 08:51:45 2014 -0500 @@ -94,7 +94,10 @@ // Read header and name. xreadall(afd, toybuf, 110); tofree = name = strpad(afd, x8u(toybuf+94), 110); - if (!strcmp("TRAILER!!!", name)) break; + if (!strcmp("TRAILER!!!", name)) { + if (CFG_TOYBOX_FREE) free(tofree); + break; + } // If you want to extract absolute paths, "cd /" and run cpio. while (*name == '/') name++; @@ -121,6 +124,7 @@ } else if (S_ISLNK(mode)) { data = strpad(afd, size, 0); if (!test) err = symlink(data, name); + free(data); // Can't get a filehandle to a symlink, so do special chown if (!err && !getpid()) err = lchown(name, uid, gid); } else if (S_ISREG(mode)) { @@ -249,4 +253,5 @@ xwrite(afd, toybuf, sprintf(toybuf, "070701%040X%056X%08XTRAILER!!!", 1, 0x0b, 0)+4); } + if (TT.archive) xclose(afd); }