summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-12 23:26:31 -0500
committerpommicket <pommicket@gmail.com>2023-01-12 23:26:31 -0500
commit75dad99bb72d81a69e6bddee0279835683e6c27b (patch)
treed2eb7bd36f6087563a3e0c9b2656064171f87791 /util.c
parentba0aed7ab927a6d7c96d1191896f8cfdfae563de (diff)
[2.0] fix path_full on windows
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);