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

Unified Diff: bin/file_macos.cc

Issue 8400070: Allocate and pass a resolved_path buffer to realpath as older macos versions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/file_macos.cc
===================================================================
--- bin/file_macos.cc (revision 898)
+++ bin/file_macos.cc (working copy)
@@ -7,6 +7,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <libgen.h>
+#include <limits.h>
#include "bin/builtin.h"
#include "bin/file.h"
@@ -122,7 +123,13 @@
char* File::GetCanonicalPath(const char* pathname) {
char* abs_path = NULL;
if (pathname != NULL) {
- abs_path = realpath(pathname, NULL);
+ // On some older MacOs versions the default behaviour of realpath allocating
+ // space for the resolved_path when a NULL is passed in does not seem to
+ // work, so we explicitly allocate space. The caller is responsible for
+ // freeing this space as in a regular realpath call.
+ char* resolved_path = reinterpret_cast<char*>(malloc(PATH_MAX+1));
+ ASSERT(resolved_path != NULL);
+ abs_path = realpath(pathname, resolved_path);
assert(abs_path == NULL || IsAbsolutePath(abs_path));
}
return abs_path;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698