From: Antoine Pitrou Date: Sun, 21 Oct 2012 14:33:33 +0000 (+0200) Subject: Issue #12034: Fix bogus caching of result in check_GetFinalPathNameByHandle. X-Git-Tag: v3.4.0a1~2205 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06eecead03a7698ca7a1d15548e6bf35fab2dbfb;p=python Issue #12034: Fix bogus caching of result in check_GetFinalPathNameByHandle. Patch by Atsuo Ishimoto. --- diff --git a/Misc/NEWS b/Misc/NEWS index 91ebfacee7..0f66e8def7 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -59,6 +59,9 @@ Core and Builtins Library ------- +- Issue #12034: Fix bogus caching of result in check_GetFinalPathNameByHandle. + Patch by Atsuo Ishimoto. + - Issue #16220: wsgiref now always calls close() on an iterable response. Patch by Brent Tubbs. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 1089ae399b..0fe3963d18 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1390,7 +1390,7 @@ attributes_from_dir_w(LPCWSTR pszFile, BY_HANDLE_FILE_INFORMATION *info, ULONG * } /* Grab GetFinalPathNameByHandle dynamically from kernel32 */ -static int has_GetFinalPathNameByHandle = 0; +static int has_GetFinalPathNameByHandle = -1; static DWORD (CALLBACK *Py_GetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD); static int @@ -1401,7 +1401,7 @@ check_GetFinalPathNameByHandle() DWORD); /* only recheck */ - if (!has_GetFinalPathNameByHandle) + if (-1 == has_GetFinalPathNameByHandle) { hKernel32 = GetModuleHandleW(L"KERNEL32"); *(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32,