Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(925)

Unified Diff: runtime/bin/file_win.cc

Issue 2426053002: Fix crashes on debug windows (Closed)
Patch Set: Cleanup Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« runtime/bin/file.h ('K') | « runtime/bin/file.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_win.cc
diff --git a/runtime/bin/file_win.cc b/runtime/bin/file_win.cc
index c9f98b560a1e375feea1684c6ed4bde87550611b..28788430ea6df54f8794d5b7dd6731928ef3b12f 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -635,7 +635,12 @@ File::StdioHandleType File::GetStdioHandleType(int fd) {
File::Type File::GetType(const char* pathname, bool follow_links) {
- const wchar_t* name = StringUtilsWin::Utf8ToWide(pathname);
+ // Convert to wchar_t string.
+ int name_len = MultiByteToWideChar(CP_UTF8, 0, pathname, -1, NULL, 0);
+ wchar_t* name;
+ name = new wchar_t[name_len];
+ MultiByteToWideChar(CP_UTF8, 0, pathname, -1, name, name_len);
+
DWORD attributes = GetFileAttributesW(name);
File::Type result = kIsFile;
if (attributes == INVALID_FILE_ATTRIBUTES) {
@@ -662,6 +667,7 @@ File::Type File::GetType(const char* pathname, bool follow_links) {
} else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
result = kIsDirectory;
}
+ delete[] name;
return result;
}
« runtime/bin/file.h ('K') | « runtime/bin/file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698