merge from trunk
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 12ee9a8..c725b7d 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -751,11 +751,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)