aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-01-12 13:56:47 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-01-21 10:56:45 +0000
commitbd49260e413dfecf6ce32c771cb81f2586cc67da (patch)
tree156ae79f2cb928c24da2ea963b51cc1aaf2bb927 /selection.c
parentchangelog: add hyphen between ‘newline’ and ‘terminated’ (diff)
selection: uri decode: move zero-length check into decode_one_uri()
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/selection.c b/selection.c
index 8a1e2943..7f94b0a7 100644
--- a/selection.c
+++ b/selection.c
@@ -1213,6 +1213,9 @@ decode_one_uri(struct clipboard_receive *ctx, char *uri, size_t len)
{
LOG_DBG("URI: \"%.*s\"", (int)len, uri);
+ if (len == 0)
+ return false;
+
char *scheme, *host, *path;
if (!uri_parse(uri, len, &scheme, NULL, NULL, &host, NULL, &path, NULL, NULL)) {
LOG_ERR("drag-and-drop: invalid URI: %.*s", (int)len, uri);
@@ -1267,8 +1270,7 @@ static void
fdm_receive_finish_uri(struct clipboard_receive *ctx)
{
LOG_DBG("finish: %.*s", (int)ctx->buf.idx, ctx->buf.data);
- if (ctx->buf.idx > 0)
- decode_one_uri(ctx, ctx->buf.data, ctx->buf.idx);
+ decode_one_uri(ctx, ctx->buf.data, ctx->buf.idx);
}
static bool