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
#include <ddk/ntifs.h>
#include "wide_path.h"
-static const char version[] = "$Revision: 1.57 $";
+static const char version[] = "$Revision: 1.58 $";
static char *prog_name;
static char *file_arg, *output_arg;
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;
}
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);
}
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 =
{
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)
{
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;
}
}
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