Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2010-01-07 20:19:12 +0300
committerCorinna Vinschen <corinna@vinschen.de>2010-01-07 20:19:12 +0300
commitbf4b80201a7ed3f75cf99f868628ebad1525f100 (patch)
tree3e6f2c84e5a77523f6053dbeac954c90a32835d6
parent781be3b173ec31061588571c4d9e6c017c0e7505 (diff)
* cygpath.cc: Throughout, free obsolete path buffers.
-rw-r--r--winsup/utils/ChangeLog4
-rw-r--r--winsup/utils/cygpath.cc60
2 files changed, 52 insertions, 12 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index e3bab28ab..a8438b57a 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,5 +1,9 @@
2010-01-07 Corinna Vinschen <corinna@vinschen.de>
+ * cygpath.cc: Throughout, free obsolete path buffers.
+
+2010-01-07 Corinna Vinschen <corinna@vinschen.de>
+
* cygpath.cc (main): Remove enforcing "en_US.UTF-8" locale.
Revert usage of argz functions when reading input from file and
simplify option usage. Allow only one option argument and use
diff --git a/winsup/utils/cygpath.cc b/winsup/utils/cygpath.cc
index 3f6e5a9cc..02b490902 100644
--- a/winsup/utils/cygpath.cc
+++ b/winsup/utils/cygpath.cc
@@ -226,6 +226,7 @@ get_device_name (char *path)
a valid DOS device name, if prepended with "\\.\". Return that
valid DOS path. */
ULONG len = RtlUnicodeStringToAnsiSize (&odi->ObjectName);
+ free (ret);
ret = (char *) malloc (len + 4);
strcpy (ret, "\\\\.\\");
ans.Length = 0;
@@ -666,10 +667,18 @@ do_sysfolders (char option)
}
else
{
+ char *tmp;
+
if (shortname_flag)
- buf = get_short_name (buf);
+ {
+ buf = get_short_name (tmp = buf);
+ free (tmp);
+ }
if (mixed_flag)
- buf = get_mixed_name (buf);
+ {
+ buf = get_mixed_name (tmp = buf);
+ free (tmp);
+ }
}
printf ("%s\n", buf);
}
@@ -695,8 +704,8 @@ report_mode (char *filename)
static void
do_pathconv (char *filename)
{
- char *buf;
- wchar_t *buf2;
+ char *buf = NULL, *tmp;
+ wchar_t *buf2 = NULL;
DWORD len;
ssize_t err;
cygwin_conv_path_t conv_func =
@@ -737,13 +746,23 @@ do_pathconv (char *filename)
{
if (err)
/* oops */;
- buf = get_device_paths (buf);
+ buf = get_device_paths (tmp = buf);
+ free (tmp);
if (shortname_flag)
- buf = get_short_paths (buf);
+ {
+ buf = get_short_paths (tmp = buf);
+ free (tmp);
+ }
if (longname_flag)
- buf = get_long_paths (buf);
+ {
+ buf = get_long_paths (tmp = buf);
+ free (tmp);
+ }
if (mixed_flag)
- buf = get_mixed_name (buf);
+ {
+ buf = get_mixed_name (tmp = buf);
+ free (tmp);
+ }
}
if (err)
{
@@ -765,11 +784,21 @@ do_pathconv (char *filename)
if (!unix_flag)
{
my_wcstombs (buf, buf2, 32768);
- buf = get_device_name (buf);
+ buf = get_device_name (tmp = buf);
+ free (tmp);
if (shortname_flag)
- buf = get_short_name (buf);
+ {
+ buf = get_short_name (tmp = buf);
+ free (tmp);
+ }
if (longname_flag)
- buf = get_long_name (buf, len);
+ {
+ buf = get_long_name (tmp = buf, len);
+ free (tmp);
+ }
+ /* buf gets moved into the array so we have to set tmp for later
+ freeing beforehand. */
+ tmp = buf;
if (strncmp (buf, "\\\\?\\", 4) == 0)
{
len = 4;
@@ -783,11 +812,18 @@ do_pathconv (char *filename)
}
}
if (mixed_flag)
- buf = get_mixed_name (buf);
+ {
+ buf = get_mixed_name (buf);
+ free (tmp);
+ }
}
}
puts (buf);
+ if (buf2)
+ free (buf2);
+ if (buf)
+ free (buf);
}
static void