From 637d976c195d690ef96344fd7415cfc29546b868 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 6 Apr 2012 00:55:04 +0200 Subject: [PATCH] Revert "Fix memory leak in uv_exepath() on OSX." This reverts commit f6c8e78db973a0f57424dba74c97fdd4d2f910f8. realpath() on OS X 10.5 crashes if resolved_path == NULL. --- src/unix/darwin.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unix/darwin.c b/src/unix/darwin.c index 6b3705f6..e6deb301 100644 --- a/src/unix/darwin.c +++ b/src/unix/darwin.c @@ -73,6 +73,7 @@ uint64_t uv_hrtime() { int uv_exepath(char* buffer, size_t* size) { uint32_t usize; int result; + char* path; char* fullpath; if (!buffer || !size) { @@ -83,9 +84,11 @@ int uv_exepath(char* buffer, size_t* size) { result = _NSGetExecutablePath(buffer, &usize); if (result) return result; - fullpath = realpath(buffer, NULL); + path = (char*)malloc(2 * PATH_MAX); + fullpath = realpath(buffer, path); if (fullpath == NULL) { + free(path); return -1; }