Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Fix memory leak in uv_exepath() on OSX.
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 authored and bnoordhuis committed Feb 24, 2012
1 parent fbc2154 commit f6c8e78
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/unix/darwin.c
Expand Up @@ -73,7 +73,6 @@ uint64_t uv_hrtime() {
int uv_exepath(char* buffer, size_t* size) {
uint32_t usize;
int result;
char* path;
char* fullpath;

if (!buffer || !size) {
Expand All @@ -84,11 +83,9 @@ int uv_exepath(char* buffer, size_t* size) {
result = _NSGetExecutablePath(buffer, &usize);
if (result) return result;

path = (char*)malloc(2 * PATH_MAX);
fullpath = realpath(buffer, path);
fullpath = realpath(buffer, NULL);

if (fullpath == NULL) {
free(path);
return -1;
}

Expand Down

1 comment on commit f6c8e78

@bnoordhuis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jedisct1: Frank, I reverted this commit in 637d976, it segfaulted on OS X 10.5 (all according to spec sigh). Looking at it again, ISTM that there's no memory leak here, the malloc'd buffer is freed in both code paths.

Please sign in to comment.