diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-02-07 06:38:46 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-02-07 06:38:46 -0500 |
commit | 969d7480ea15d36c5fdd10827b30d22c81bd2eb5 (patch) | |
tree | ce907a2923c45f7d8db721f2c08e6333db6bbf64 | |
parent | gen_symbol_version_map.awk: filter out more symbols (diff) | |
download | sandbox-969d7480ea15d36c5fdd10827b30d22c81bd2eb5.tar.gz sandbox-969d7480ea15d36c5fdd10827b30d22c81bd2eb5.tar.bz2 sandbox-969d7480ea15d36c5fdd10827b30d22c81bd2eb5.zip |
libsandbox: fix minor memleak from cmdline simplification
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r-- | libsandbox/libsandbox.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c index b3ed79b..e881f59 100644 --- a/libsandbox/libsandbox.c +++ b/libsandbox/libsandbox.c @@ -365,20 +365,21 @@ static int write_logfile(const char *logfile, const char *func, const char *path if (cmdlinefd != -1) { size_t pagesz = getpagesize(); char *buf = xmalloc(pagesz); - size_t len, i; while (1) { - len = sb_read(cmdlinefd, buf, pagesz); + size_t len = sb_read(cmdlinefd, buf, pagesz); if (len == -1) { SB_EERROR("ISE:write_logfile ", "cmdlinefd read error\n"); break; } else if (!len) break; + size_t i; for (i = 0; i < len; ++i) if (!buf[i]) buf[i] = ' '; SB_WRITE(logfd, buf, len, error); } sb_close(cmdlinefd); + free(buf); } else _SB_WRITE_STR("<unable to read " PROC_SELF_CMDLINE ">"); _SB_WRITE_STR("\n"); |