From 3eb4fa15ee4c9297cc77ce69fcfcd5d7192462f4 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Thu, 28 Dec 2017 09:44:35 +0100 Subject: ENOMEM checks: consistently check wl_array_add return --- xwayland/selection.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'xwayland') 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; } -- cgit v1.2.3