aboutsummaryrefslogtreecommitdiff
path: root/xwayland
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2017-12-28 09:44:35 +0100
committerDominique Martinet <asmadeus@codewreck.org>2017-12-28 09:48:35 +0100
commit3eb4fa15ee4c9297cc77ce69fcfcd5d7192462f4 (patch)
tree7de548365be376476749d8b4a179d12eaacb5901 /xwayland
parent9c163b7d38f859df0f6b21d04ff4267df74dd290 (diff)
ENOMEM checks: consistently check wl_array_add return
Diffstat (limited to 'xwayland')
-rw-r--r--xwayland/selection.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/xwayland/selection.c b/xwayland/selection.c
index 0d7f1588..280df583 100644
--- a/xwayland/selection.c
+++ b/xwayland/selection.c
@@ -55,6 +55,15 @@ 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 to read into, throwing away some input");
+ /* if we just return now, we'll just be called
+ * again right away - force read something.
+ * 1K on stack is probably fine? */
+ char junk[1024];
+ read(fd, junk, sizeof(junk));
+ return 1;
+ }
} else {
p = (char *) selection->source_data.data + selection->source_data.size;
}