Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* maint:
  Don't crash when getcwd() fails
  • Loading branch information
jrosdahl committed Aug 3, 2011
2 parents 2fb75b8 + 83f5a1e commit cce69f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ccache.c
Expand Up @@ -2186,6 +2186,10 @@ ccache_main(int argc, char *argv[])
}

current_working_dir = get_cwd();
if (!current_working_dir) {
cc_log("Could not determine current working directory");
failed();
}
cache_dir = getenv("CCACHE_DIR");
if (cache_dir) {
cache_dir = x_strdup(cache_dir);
Expand Down
6 changes: 5 additions & 1 deletion util.c
Expand Up @@ -905,7 +905,8 @@ gnu_getcwd(void)
}
free(buffer);
if (errno != ERANGE) {
return 0;
cc_log("getcwd error: %d (%s)", errno, strerror(errno));
return NULL;
}
size *= 2;
}
Expand Down Expand Up @@ -987,6 +988,9 @@ get_cwd(void)
struct stat st_cwd;

cwd = gnu_getcwd();
if (!cwd) {
return NULL;
}
pwd = getenv("PWD");
if (!pwd) {
return cwd;
Expand Down

0 comments on commit cce69f0

Please sign in to comment.