summaryrefslogtreecommitdiff
path: root/utils/url.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/url.c')
-rw-r--r--utils/url.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/utils/url.c b/utils/url.c
index c1d2c5a48..f5ed80036 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -329,7 +329,7 @@ char *url_join(const char *rel, const char *base)
path = buf;
step7: /* 7) */
- res = malloc(scheme_len + 1 + 2 + authority_len + path_len + 1 +
+ res = malloc(scheme_len + 1 + 2 + authority_len + path_len + 1 + 1 +
query_len + 1 + fragment_len + 1);
if (!res) {
LOG(("malloc failed"));
@@ -346,8 +346,12 @@ step7: /* 7) */
strncpy(res + i, authority, authority_len);
i += authority_len;
}
- strncpy(res + i, path, path_len);
- i += path_len;
+ if (path_len) {
+ strncpy(res + i, path, path_len);
+ i += path_len;
+ } else {
+ res[i++] = '/';
+ }
if (query) {
res[i++] = '?';
strncpy(res + i, query, query_len);