* cygpath.cc: Throughout, free obsolete path buffers.

This commit is contained in:
Corinna Vinschen 2010-01-07 17:19:12 +00:00
parent 781be3b173
commit bf4b80201a
2 changed files with 52 additions and 12 deletions

View File

@ -1,3 +1,7 @@
2010-01-07 Corinna Vinschen <corinna@vinschen.de>
* cygpath.cc: Throughout, free obsolete path buffers.
2010-01-07 Corinna Vinschen <corinna@vinschen.de> 2010-01-07 Corinna Vinschen <corinna@vinschen.de>
* cygpath.cc (main): Remove enforcing "en_US.UTF-8" locale. * cygpath.cc (main): Remove enforcing "en_US.UTF-8" locale.

View File

@ -226,6 +226,7 @@ get_device_name (char *path)
a valid DOS device name, if prepended with "\\.\". Return that a valid DOS device name, if prepended with "\\.\". Return that
valid DOS path. */ valid DOS path. */
ULONG len = RtlUnicodeStringToAnsiSize (&odi->ObjectName); ULONG len = RtlUnicodeStringToAnsiSize (&odi->ObjectName);
free (ret);
ret = (char *) malloc (len + 4); ret = (char *) malloc (len + 4);
strcpy (ret, "\\\\.\\"); strcpy (ret, "\\\\.\\");
ans.Length = 0; ans.Length = 0;
@ -666,10 +667,18 @@ do_sysfolders (char option)
} }
else else
{ {
char *tmp;
if (shortname_flag) if (shortname_flag)
buf = get_short_name (buf); {
buf = get_short_name (tmp = buf);
free (tmp);
}
if (mixed_flag) if (mixed_flag)
buf = get_mixed_name (buf); {
buf = get_mixed_name (tmp = buf);
free (tmp);
}
} }
printf ("%s\n", buf); printf ("%s\n", buf);
} }
@ -695,8 +704,8 @@ report_mode (char *filename)
static void static void
do_pathconv (char *filename) do_pathconv (char *filename)
{ {
char *buf; char *buf = NULL, *tmp;
wchar_t *buf2; wchar_t *buf2 = NULL;
DWORD len; DWORD len;
ssize_t err; ssize_t err;
cygwin_conv_path_t conv_func = cygwin_conv_path_t conv_func =
@ -737,13 +746,23 @@ do_pathconv (char *filename)
{ {
if (err) if (err)
/* oops */; /* oops */;
buf = get_device_paths (buf); buf = get_device_paths (tmp = buf);
free (tmp);
if (shortname_flag) if (shortname_flag)
buf = get_short_paths (buf); {
buf = get_short_paths (tmp = buf);
free (tmp);
}
if (longname_flag) if (longname_flag)
buf = get_long_paths (buf); {
buf = get_long_paths (tmp = buf);
free (tmp);
}
if (mixed_flag) if (mixed_flag)
buf = get_mixed_name (buf); {
buf = get_mixed_name (tmp = buf);
free (tmp);
}
} }
if (err) if (err)
{ {
@ -765,11 +784,21 @@ do_pathconv (char *filename)
if (!unix_flag) if (!unix_flag)
{ {
my_wcstombs (buf, buf2, 32768); my_wcstombs (buf, buf2, 32768);
buf = get_device_name (buf); buf = get_device_name (tmp = buf);
free (tmp);
if (shortname_flag) if (shortname_flag)
buf = get_short_name (buf); {
buf = get_short_name (tmp = buf);
free (tmp);
}
if (longname_flag) 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) if (strncmp (buf, "\\\\?\\", 4) == 0)
{ {
len = 4; len = 4;
@ -783,11 +812,18 @@ do_pathconv (char *filename)
} }
} }
if (mixed_flag) if (mixed_flag)
buf = get_mixed_name (buf); {
buf = get_mixed_name (buf);
free (tmp);
}
} }
} }
puts (buf); puts (buf);
if (buf2)
free (buf2);
if (buf)
free (buf);
} }
static void static void