diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2012-01-16 22:35:39 +0100 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2012-01-16 22:35:39 +0100 |
commit | e74b07331ecc57ee9be68a5f09cdb6447215e56c (patch) | |
tree | 4c5fa392eeeda41991f58dc64b3330bde895fd24 /ccache.c | |
parent | 7633687271ed821461e799a6d41822179bf431f1 (diff) | |
download | ccache-e74b07331ecc57ee9be68a5f09cdb6447215e56c.tar.gz |
Don't crash when current working directory doesn't exist
Diffstat (limited to 'ccache.c')
-rw-r--r-- | ccache.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -392,6 +392,15 @@ make_relative_path(char *path) return path; } + if (!current_working_dir) { + current_working_dir = get_cwd(); + if (!current_working_dir) { + cc_log("Unable to determine current working directory: %s", + strerror(errno)); + failed(); + } + } + relpath = get_relative_path(current_working_dir, path); free(path); return relpath; @@ -2160,11 +2169,6 @@ 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); |