summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/util.c b/util.c
index a0e91aa..f7cbfbc 100644
--- a/util.c
+++ b/util.c
@@ -384,11 +384,15 @@ void path_full(const char *dir, const char *relpath, char *abspath, size_t abspa
} else if (component_len == 2 && relpath[0] == '.' && relpath[1] == '.') {
// ..
char *lastsep = strrchr(abspath, PATH_SEPARATOR);
- assert(lastsep);
- if (lastsep == abspath)
- lastsep[1] = '\0';
- else
- lastsep[0] = '\0';
+ if (lastsep) {
+ if (lastsep == abspath)
+ lastsep[1] = '\0'; // e.g. /abc
+ else
+ lastsep[0] = '\0';
+ } else {
+ // e.g. if abspath is currently C:
+ // (do nothing)
+ }
} else {
if (len == 0 || abspath[len - 1] != PATH_SEPARATOR)
str_cat(abspath, abspath_size, PATH_SEPARATOR_STR);