fix archiver (ar) crash on FreeBSD (looks like a bug in cctools itself)

This commit is contained in:
Thomas Pöchtrager 2013-12-14 10:11:10 +01:00
parent 2f0f00d237
commit a4141a2e92

View File

@ -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));
}