win32: do not call GetVolumePathName() with the minimum buffer length
It fails on Windows XP even though the doc says "a safer but slower way to
set the size of the return buffer is to call the GetFullPathName function,
and then make sure that the buffer size is at least the same size as the full
path that GetFullPathName returns."
https://msdn.microsoft.com/en-us/library/windows/desktop/
aa364996(v=vs.85).aspx
Well, more "safe" way would be to simply rely on MAX_PATH for common scenarios.
--- a/mercurial/win32.py Tue Jan 02 12:02:25 2018 +0900
+++ b/mercurial/win32.py Tue Jan 02 12:14:08 2018 +0900
@@ -439,7 +439,9 @@
# realpath() calls GetFullPathName()
realpath = os.path.realpath(path)
- size = len(realpath) + 1
+ # allocate at least MAX_PATH long since GetVolumePathName('c:\\', buf, 4)
+ # somehow fails on Windows XP
+ size = max(len(realpath), _MAX_PATH) + 1
buf = ctypes.create_string_buffer(size)
if not _kernel32.GetVolumePathNameA(realpath, ctypes.byref(buf), size):