From 9d4f0a373cae0967de7ee73dcfb6b2ee00ee481a Mon Sep 17 00:00:00 2001 From: James Bursa Date: Mon, 12 Apr 2004 20:43:29 +0000 Subject: [project @ 2004-04-12 20:43:29 by bursa] Fix bug in url_join(). svn path=/import/netsurf/; revision=763 --- utils/url.c | 10 +++++++--- 1 file 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); -- cgit v1.2.3