Index: path.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/path.cc,v retrieving revision 1.388 diff -u -p -b -r1.388 path.cc --- path.cc 25 Aug 2005 21:18:26 -0000 1.388 +++ path.cc 26 Aug 2005 13:07:29 -0000 @@ -50,6 +50,7 @@ details. */ #include "winsup.h" #include #include +#include #include #include #include @@ -3657,6 +3658,8 @@ realpath (const char *path, char *resolv /* Make sure the right errno is returned if path is NULL. */ if (!path) { + if (resolved) + resolved[0] = '\0'; set_errno (EINVAL); return NULL; } @@ -3677,11 +3680,7 @@ realpath (const char *path, char *resolv if (!real_path.error && real_path.exists ()) { if (!resolved) - { - resolved = (char *) malloc (strlen (real_path.normalized_path) + 1); - if (!resolved) - return NULL; - } + return strdup (real_path.normalized_path); return strcpy (resolved, real_path.normalized_path); }