From 1b526b480b08c75483b56ff34bab8f0d643081cc Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 16 Jan 2010 10:25:58 +0000 Subject: [PATCH] * cygpath.cc (get_mixed_name): Drop function. Replace with call to convert_slashes throughout. (do_sysfolders): Free allocated buffer. (do_pathconv): Fix freeing last buffer. --- winsup/utils/ChangeLog | 7 +++++++ winsup/utils/cygpath.cc | 43 ++++++++--------------------------------- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index ba588d5ad..e33d8f2b0 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,10 @@ +2010-01-16 Corinna Vinschen + + * cygpath.cc (get_mixed_name): Drop function. Replace with call to + convert_slashes throughout. + (do_sysfolders): Free allocated buffer. + (do_pathconv): Fix freeing last buffer. + 2010-01-11 Corinna Vinschen * mount.cc (do_mount_from_fstab): Allow to change cygdrive prefix, too. diff --git a/winsup/utils/cygpath.cc b/winsup/utils/cygpath.cc index 02b490902..2b9fed419 100644 --- a/winsup/utils/cygpath.cc +++ b/winsup/utils/cygpath.cc @@ -539,22 +539,6 @@ convert_slashes (char* name) } } -static char * -get_mixed_name (const char* filename) -{ - char* mixed_buf = strdup (filename); - - if (mixed_buf == NULL) - { - fprintf (stderr, "%s: out of memory\n", prog_name); - exit (1); - } - - convert_slashes (mixed_buf); - - return mixed_buf; -} - static bool get_special_folder (char* path, int id) { @@ -575,6 +559,7 @@ static void do_sysfolders (char option) { char *buf, buf1[PATH_MAX], buf2[PATH_MAX]; + char *tmp = NULL; WCHAR wbuf[MAX_PATH]; DWORD len = MAX_PATH; WIN32_FIND_DATAW w32_fd; @@ -667,20 +652,14 @@ do_sysfolders (char option) } else { - char *tmp; - if (shortname_flag) - { - buf = get_short_name (tmp = buf); - free (tmp); - } + tmp = buf = get_short_name (buf); if (mixed_flag) - { - buf = get_mixed_name (tmp = buf); - free (tmp); - } + convert_slashes (buf); } printf ("%s\n", buf); + if (tmp) + free (tmp); } static void @@ -759,10 +738,7 @@ do_pathconv (char *filename) free (tmp); } if (mixed_flag) - { - buf = get_mixed_name (tmp = buf); - free (tmp); - } + convert_slashes (buf); } if (err) { @@ -812,10 +788,7 @@ do_pathconv (char *filename) } } if (mixed_flag) - { - buf = get_mixed_name (buf); - free (tmp); - } + convert_slashes (buf); } } @@ -823,7 +796,7 @@ do_pathconv (char *filename) if (buf2) free (buf2); if (buf) - free (buf); + free (tmp); } static void