commit 9f89adb7860684de4898d2dc7c958d692ef9b320
parent 745ce8b59ab23d749970f394704fe462eafcb6ec
Author: Michael Forney <mforney@mforney.org>
Date: Sun, 2 Nov 2014 01:22:33 +0000
wayland-shm: Handle potential malloc failure
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/wayland-shm.c b/wayland-shm.c
@@ -285,7 +285,10 @@ void registry_global_remove(void * data, struct wl_registry * registry,
void shm_format(void * data, struct wl_shm * wl, uint32_t format)
{
struct shm_context * context = data;
+ uint32_t * added_format;
- *((uint32_t *) wl_array_add(&context->formats, sizeof format)) = format;
+ if (!(added_format = wl_array_add(&context->formats, sizeof format)))
+ return;
+ *added_format = format;
}