aboutsummaryrefslogtreecommitdiff
path: root/xwayland/selection.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-12-28 07:44:21 -0800
committerGitHub <noreply@github.com>2017-12-28 07:44:21 -0800
commitbb24895a2b1759ec78ae68bb91d13a98dc3cc9c7 (patch)
tree8c76d2152a6b21f98c879a2b5ecf4dfb05d3ff9c /xwayland/selection.c
parent04b7701e1b7a7f371caffecafae07467aa8970e7 (diff)
parentb0e440b5b1e1de0030947c68cdc34b0fd902c5e8 (diff)
Merge pull request #533 from martinetd/wl_array_add
ENOMEM checks: consistently check wl_array_add return
Diffstat (limited to 'xwayland/selection.c')
-rw-r--r--xwayland/selection.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/xwayland/selection.c b/xwayland/selection.c
index 0d7f1588..00e45182 100644
--- a/xwayland/selection.c
+++ b/xwayland/selection.c
@@ -55,6 +55,10 @@ static int xwm_read_data_source(int fd, uint32_t mask, void *data) {
int current = selection->source_data.size;
if (selection->source_data.size < incr_chunk_size) {
p = wl_array_add(&selection->source_data, incr_chunk_size);
+ if (!p){
+ wlr_log(L_ERROR, "Could not allocate selection source_data");
+ goto error_out;
+ }
} else {
p = (char *) selection->source_data.data + selection->source_data.size;
}
@@ -64,11 +68,7 @@ static int xwm_read_data_source(int fd, uint32_t mask, void *data) {
int len = read(fd, p, available);
if (len == -1) {
wlr_log(L_ERROR, "read error from data source: %m");
- xwm_selection_send_notify(selection, XCB_ATOM_NONE);
- wl_event_source_remove(selection->property_source);
- selection->property_source = NULL;
- close(fd);
- wl_array_release(&selection->source_data);
+ goto error_out;
}
wlr_log(L_DEBUG, "read %d (available %d, mask 0x%x) bytes: \"%.*s\"",
@@ -140,6 +140,14 @@ static int xwm_read_data_source(int fd, uint32_t mask, void *data) {
}
return 1;
+
+error_out:
+ xwm_selection_send_notify(selection, XCB_ATOM_NONE);
+ wl_event_source_remove(selection->property_source);
+ selection->property_source = NULL;
+ close(fd);
+ wl_array_release(&selection->source_data);
+ return 0;
}
static void xwm_selection_source_send(struct wlr_xwm_selection *selection,