summaryrefslogtreecommitdiffstats
path: root/Utilities/cmtar/output.c
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2006-02-03 16:48:44 (GMT)
committerDavid Cole <david.cole@kitware.com>2006-02-03 16:48:44 (GMT)
commit0323a0d6d20402d994f4f886d51b8c33c02ed73a (patch)
tree9ac42eed35f442353e0068fbe898120444f853a5 /Utilities/cmtar/output.c
parentafa83678854b7af547c9f0033ac5f7446a163447 (diff)
downloadCMake-0323a0d6d20402d994f4f886d51b8c33c02ed73a.zip
CMake-0323a0d6d20402d994f4f886d51b8c33c02ed73a.tar.gz
CMake-0323a0d6d20402d994f4f886d51b8c33c02ed73a.tar.bz2
BUG: Fix mem leaks related to th_get_pathname. Change this implementation of th_get_pathname so that it *always* returns a strdup'ed value. Callers must now free non-NULL returns from th_get_pathname. Change all callers to call free appropriately.
Diffstat (limited to 'Utilities/cmtar/output.c')
-rw-r--r--Utilities/cmtar/output.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Utilities/cmtar/output.c b/Utilities/cmtar/output.c
index 38cf157..a60cde2 100644
--- a/Utilities/cmtar/output.c
+++ b/Utilities/cmtar/output.c
@@ -76,6 +76,7 @@ th_print_long_ls(TAR *t)
char groupname[_POSIX_LOGIN_NAME_MAX];
time_t mtime;
struct tm *mtm;
+ char *pathname = 0;
#ifdef HAVE_STRFTIME
char timebuf[18];
@@ -124,7 +125,12 @@ th_print_long_ls(TAR *t)
mtm->tm_mday, mtm->tm_hour, mtm->tm_min, mtm->tm_year + 1900);
#endif
- printf(" %s", th_get_pathname(t));
+ pathname = th_get_pathname(t);
+ if (pathname)
+ {
+ printf(" %s", pathname);
+ free(pathname);
+ }
#if !defined(_WIN32) || defined(__CYGWIN__)
if (TH_ISSYM(t) || TH_ISLNK(t))
@@ -142,5 +148,3 @@ th_print_long_ls(TAR *t)
putchar('\n');
}
-
-