alloc buffer for getcwd
svn: r5355
This commit is contained in:
parent
32ec113ed1
commit
0a36385258
|
@ -140,6 +140,8 @@ static char *copy_string(char *s1)
|
|||
int l1;
|
||||
char *s;
|
||||
|
||||
if (!s1) return NULL;
|
||||
|
||||
l1 = strlen(s1);
|
||||
|
||||
s = (char *)malloc(l1 + 1);
|
||||
|
@ -199,6 +201,9 @@ char *absolutize(char *p, char *d)
|
|||
{
|
||||
int l1;
|
||||
|
||||
if (!p[0])
|
||||
return p;
|
||||
|
||||
if (p[0] == '/')
|
||||
return p;
|
||||
|
||||
|
@ -235,7 +240,10 @@ int main(int argc, char **argv)
|
|||
/* Absolute path */
|
||||
} else if (has_slash(me)) {
|
||||
/* Relative path with a directory: */
|
||||
me = path_append(getcwd(NULL, 0), me);
|
||||
char *buf;
|
||||
long buflen = 4096;
|
||||
buf = (char *)malloc(buflen);
|
||||
me = path_append(getcwd(buf, buflen), me);
|
||||
} else {
|
||||
/* We have to find the executable by searching PATH: */
|
||||
char *path = copy_string(getenv("PATH")), *p, *m;
|
||||
|
|
Loading…
Reference in New Issue
Block a user