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

Unified Diff: runtime/bin/directory_macos.cc

Issue 1800863002: Cleanup in //runtime/bin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Windows fixes Created 4 years, 9 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
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);
}

Powered by Google App Engine
This is Rietveld 408576698