summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/util.c b/util.c
index 5008058..42d9387 100644
--- a/util.c
+++ b/util.c
@@ -265,6 +265,7 @@ static bool path_is_absolute(char const *path) {
// assuming `dir` is an absolute path, returns the absolute path of `relpath`, relative to `dir`.
static void path_full(char const *dir, char const *relpath, char *abspath, size_t abspath_size) {
assert(abspath_size);
+ assert(dir[0]);
abspath[0] = '\0';
if (path_is_absolute(relpath)) {
@@ -281,7 +282,8 @@ static void path_full(char const *dir, char const *relpath, char *abspath, size_
} else {
str_cpy(abspath, abspath_size, dir);
}
- if (abspath[strlen(abspath) - 1] != PATH_SEPARATOR)
+
+ if (strlen(abspath) == 0 || abspath[strlen(abspath) - 1] != PATH_SEPARATOR)
str_cat(abspath, abspath_size, PATH_SEPARATOR_STR);
while (*relpath) {