aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-05 07:40:24 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-05 07:40:24 +0000
commit1207ad1502d82d0acd079cd702a267bd2f70d90e (patch)
tree4285e24439b961df4a02a9570a447c9c34c16a79 /selection.c
parentselection: remove debug assert (diff)
selection: free strdup:ed clipboard data on fdm failure
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/selection.c b/selection.c
index c6361809..2bb9b22a 100644
--- a/selection.c
+++ b/selection.c
@@ -364,6 +364,8 @@ send(void *data, struct wl_data_source *wl_data_source, const char *mime_type,
const char *selection = clipboard->text;
const size_t len = strlen(selection);
+ /* Make it NONBLOCK:ing right away - we don't want to block if the
+ * initial attempt to send the data synchronously fails */
int flags;
if ((flags = fcntl(fd, F_GETFL)) < 0 ||
fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0)
@@ -384,6 +386,7 @@ send(void *data, struct wl_data_source *wl_data_source, const char *mime_type,
if (fdm_add(wayl->fdm, fd, EPOLLOUT, &fdm_send, ctx))
return;
+ free(ctx->data);
free(ctx);
break;
}
@@ -474,6 +477,7 @@ primary_send(void *data,
if (fdm_add(wayl->fdm, fd, EPOLLOUT, &fdm_send, ctx))
return;
+ free(ctx->data);
free(ctx);
break;
}