diff Modules/posixmodule.c @ 49482:a0258baed005 2.6

Merged revisions 66809-66810,66835,66862-66863 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r66809 | hirokazu.yamamoto | 2008-10-06 10:57:03 +0900 | 1 line Added the test for issue3762. ........ r66810 | hirokazu.yamamoto | 2008-10-06 11:41:59 +0900 | 1 line More strict test. Consider the case sys.executable itself is symlink. ........ r66835 | hirokazu.yamamoto | 2008-10-08 03:10:47 +0900 | 1 line more intensive test on dbm. ........ r66862 | hirokazu.yamamoto | 2008-10-09 19:00:30 +0900 | 3 lines On windows, os.chdir given unicode was not working if GetCurrentDirectoryW returned a path longer than MAX_PATH. (But It's doubtful this code path is really executed because I cannot move to such directory on win2k) ........ r66863 | hirokazu.yamamoto | 2008-10-09 19:11:21 +0900 | 1 line r66862 contained memory leak. ........
author Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
date Thu, 09 Oct 2008 18:06:58 +0000
parents aaef08aa2a7e
children 89bc31e06489
line wrap: on
line diff
--- a/Modules/posixmodule.c	Wed Oct 08 19:28:36 2008 +0000
+++ b/Modules/posixmodule.c	Thu Oct 09 18:06:58 2008 +0000
@@ -726,11 +726,16 @@
 	if (!result)
 		return FALSE;
 	if (result > MAX_PATH+1) {
-		new_path = malloc(result);
+		new_path = malloc(result * sizeof(wchar_t));
 		if (!new_path) {
 			SetLastError(ERROR_OUTOFMEMORY);
 			return FALSE;
 		}
+		result = GetCurrentDirectoryW(result, new_path);
+		if (!result) {
+			free(new_path);
+			return FALSE;
+		}
 	}
 	if (wcsncmp(new_path, L"\\\\", 2) == 0 ||
 	    wcsncmp(new_path, L"//", 2) == 0)