Skip to content

Commit

Permalink
fix archiver (ar) crash on FreeBSD (looks like a bug in cctools itself)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoechtrager committed Dec 14, 2013
1 parent d6e269b commit 3a59671
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cctools/libstuff/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,19 @@ char *str)
p = allocate(bufsize);
_NSGetExecutablePath(p, &bufsize);
}
prefix = realpath(p, resolved_name);
p = rindex(prefix, '/');
if(p != NULL)
p[1] = '\0';

if (*p){
prefix = realpath(p, resolved_name);
if (prefix){
p = rindex(prefix, '/');
if(p != NULL)
p[1] = '\0';
} else{
goto invalid;
}
} else{
invalid:;
prefix = "";
}
//NOTE, here we add a target alias to command str;
return(makestr(prefix, PROGRAM_PREFIX, str, NULL));
}
Expand Down

0 comments on commit 3a59671

Please sign in to comment.