wayland: Check for potential OOM from wl_array_add()

Summary:
wl_array_add() returns NULL if it can't malloc/realloc.  This
is probably unlikely but check for it and issue a meaningful error if it
occurs.

Reviewers: cedric, devilhorns, zmike, raster

Reviewed By: raster

Subscribers: raster, cedric

Differential Revision: https://phab.enlightenment.org/D2054
This commit is contained in:
Bryce Harrington 2015-03-10 15:07:38 +09:00 committed by Carsten Haitzler (Rasterman)
parent b7f3a81f59
commit 13f4582c76
1 changed files with 5 additions and 1 deletions

View File

@ -815,7 +815,11 @@ _e_comp_wl_cb_key_down(void *event)
}
cdata->kbd.keys.size = (const char *)end - (const char *)cdata->kbd.keys.data;
k = wl_array_add(&cdata->kbd.keys, sizeof(*k));
if (!(k = wl_array_add(&cdata->kbd.keys, sizeof(*k))))
{
DBG("wl_array_add: Out of memory\n");
return;
}
*k = keycode;
if ((ec = e_client_focused_get()))