aboutsummaryrefslogtreecommitdiff
path: root/url-mode.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-13 12:58:16 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-21 19:15:31 +0000
commita99f9c9341d3e9e5133fb76006c9be54af4cbace (patch)
treefc9e6f8d804095f06dfce9ac22f8bc8ef591db0b /url-mode.c
parenturl-mode: multiple URL (parts) with the same ID is assigned a single key sequence (diff)
url-mode: activate_url(): ensure ‘scheme’, ‘host’ and ‘path’ are free:d
uri_parse() may succeed. But if the scheme isn’t “file”, or if the hostname isn’t localhost, then we failed to free ‘scheme’, ‘host’ and ‘path’.
Diffstat (limited to 'url-mode.c')
-rw-r--r--url-mode.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/url-mode.c b/url-mode.c
index 57291e87..0733a457 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -42,20 +42,24 @@ activate_url(struct seat *seat, struct terminal *term, const struct url *url)
char *scheme, *host, *path;
if (uri_parse(url->url, strlen(url->url), &scheme, NULL, NULL,
- &host, NULL, &path, NULL, NULL) &&
- strcmp(scheme, "file") == 0 &&
- hostname_is_localhost(host))
+ &host, NULL, &path, NULL, NULL))
{
- /*
- * This is a file in *this* computer. Pass only the
- * filename to the URL-launcher.
- *
- * I.e. strip the ‘file://user@host/’ prefix.
- */
- url_string = path;
+ if (strcmp(scheme, "file") == 0 && hostname_is_localhost(host)) {
+ /*
+ * This is a file in *this* computer. Pass only the
+ * filename to the URL-launcher.
+ *
+ * I.e. strip the ‘file://user@host/’ prefix.
+ */
+ url_string = path;
+ } else
+ free(path);
+
free(scheme);
free(host);
- } else
+ }
+
+ if (url_string == NULL)
url_string = xstrdup(url->url);
switch (url->action) {