mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-18 06:59:44 -05:00
ENOMEM checks: consistently check wl_array_add return
This commit is contained in:
parent
9c163b7d38
commit
3eb4fa15ee
5 changed files with 40 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue