+2009-05-29 Christopher Faylor <me+cygwin@cgf.cx>
+
+ * path.cc (cwdstuff::set): Rewrite previous change to properly test the
+ end of the buffer.
+
2009-05-28 Christopher Faylor <me+cygwin@cgf.cx>
* path.cc (cwdstuff::set): Avoid removing a nonexistent trailing slash.
pdir->Length + 2);
RtlCopyUnicodeString (&win32, pdir);
RtlReleasePebLock ();
+
+ PWSTR eoBuffer = win32.Buffer + (win32.Length / sizeof (WCHAR));
/* Remove trailing slash if one exists. FIXME: Is there a better way to
do this? */
- if (win32.Length > 3 * sizeof (WCHAR) && win32.Buffer[win32.Length - 1] == L'\\')
+ if ((eoBuffer - win32.Buffer) > 3 && eoBuffer[-1] == L'\\')
win32.Length -= sizeof (WCHAR);
+
posix_cwd = NULL;
}
else
upath.Buffer[0] = L'\\';
upath.Length = len * sizeof (WCHAR);
}
- /* Remove trailing slash if one exists. FIXME: Is there a better way to
- do this? */
- else if (upath.Length > 3 * sizeof (WCHAR) && upath.Buffer[upath.Length] == L'\\')
- upath.Length -= sizeof (WCHAR);
+ else
+ {
+ PWSTR eoBuffer = upath.Buffer + (upath.Length / sizeof (WCHAR));
+ /* Remove trailing slash if one exists. FIXME: Is there a better way to
+ do this? */
+ if ((eoBuffer - upath.Buffer) > 3 && eoBuffer[-1] == L'\\')
+ upath.Length -= sizeof (WCHAR);
+ }
RtlInitEmptyUnicodeString (&win32,
(PWCHAR) crealloc_abort (win32.Buffer,
upath.Length + 2),