There is a case that GetFullPathNameW cannot return a sufficient buffer size
when the length of the file name pass to that function is one.
SVN-Revision: 4007
l = GetFullPathNameW(wname, 0, NULL, NULL);
if (l == 0)
return (NULL);
+ /* NOTE: GetFullPathNameW has a bug that if the length of the file
+ * name is just one that return imcomplete buffer size. Thus, we
+ * have to add three to the size to allocate a sufficient buffer
+ * size for the full-pathname of the file name. */
+ l += 3;
wnp = malloc(l * sizeof(wchar_t));
if (wnp == NULL)
return (NULL);