Mercurial > hg-stable
changeset 35550:ed30934165c9
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 02 Jan 2018 12:14:08 +0900 |
parents | 94a127152e25 |
children | fa9dd53eb23e |
files | mercurial/win32.py |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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):