Index: runtime/bin/directory_macos.cc |
diff --git a/runtime/bin/directory_macos.cc b/runtime/bin/directory_macos.cc |
index a10b20a98a350adef41242d6462417ea8cffa80f..74c45333fc6a99f264cd7fba04ae777fae567737 100644 |
--- a/runtime/bin/directory_macos.cc |
+++ b/runtime/bin/directory_macos.cc |
@@ -364,20 +364,26 @@ Directory::ExistsResult Directory::Exists(const char* dir_name) { |
char* Directory::CurrentNoScope() { |
- return getcwd(NULL, 0); |
+ char buffer[PATH_MAX]; |
zra
2016/03/15 18:12:29
Changed to match other platforms.
Ivan Posva
2016/03/16 07:33:51
It looks like the original was working correctly w
zra
2016/03/16 17:00:13
I checked the Linux docs. getcwd(NULL, 0) works th
|
+ if (getcwd(buffer, PATH_MAX) == NULL) { |
+ return NULL; |
+ } |
+ return strdup(buffer); |
} |
const char* Directory::Current() { |
- char* result = DartUtils::ScopedCString(PATH_MAX); |
- ASSERT(result != NULL); |
- return getcwd(result, PATH_MAX); |
+ char buffer[PATH_MAX]; |
+ if (getcwd(buffer, PATH_MAX) == NULL) { |
zra
2016/03/15 18:12:29
Ported fix from Linux.
|
+ return NULL; |
+ } |
+ return DartUtils::ScopedCopyCString(buffer); |
} |
bool Directory::SetCurrent(const char* path) { |
int result = NO_RETRY_EXPECTED(chdir(path)); |
- return result == 0; |
+ return (result == 0); |
} |