From c13a65fd202d6e7d22e5ea0e334b50135a1d66a8 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 11 Oct 2012 23:37:44 +0200 Subject: [PATCH] wayland-util: return 0 on OOM in wl_map_insert_new() If we cannot increase the array for new entries, we now return 0 instead of accessing invalid memory. krh: Edited to return 0 on failure instead. In the initialization path, we call wl_map_insert_new() to insert NULL at index 0, which also returns 0 but not as an error. Since we do that up front, every other case of returning 0 is an unambiguous error. Signed-off-by: David Herrmann --- src/wayland-util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wayland-util.c b/src/wayland-util.c index 158f5a5..4ab1f5a 100644 --- a/src/wayland-util.c +++ b/src/wayland-util.c @@ -185,6 +185,8 @@ wl_map_insert_new(struct wl_map *map, uint32_t side, void *data) map->free_list = entry->next; } else { entry = wl_array_add(entries, sizeof *entry); + if (!entry) + return 0; start = entries->data; } -- 2.7.4