ENOMEM checks: consistently check wl_array_add return

This commit is contained in:
Dominique Martinet 2017-12-28 09:44:35 +01:00
parent 9c163b7d38
commit 3eb4fa15ee
5 changed files with 40 additions and 4 deletions

View file

@ -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;
}