diff options
| author | David Herrmann <dh.herrmann@googlemail.com> | 2012-10-11 23:37:44 +0200 |
|---|---|---|
| committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-10-15 16:08:27 -0400 |
| commit | c13a65fd202d6e7d22e5ea0e334b50135a1d66a8 (patch) | |
| tree | 8b787cc9584f7c1343e64f833d58425aa44f1fdf /src/wayland-util.c | |
| parent | wayland-util: return -1 if wl_array_copy() fails (diff) | |
| download | wayland-c13a65fd202d6e7d22e5ea0e334b50135a1d66a8.tar wayland-c13a65fd202d6e7d22e5ea0e334b50135a1d66a8.tar.gz wayland-c13a65fd202d6e7d22e5ea0e334b50135a1d66a8.tar.bz2 wayland-c13a65fd202d6e7d22e5ea0e334b50135a1d66a8.tar.lz wayland-c13a65fd202d6e7d22e5ea0e334b50135a1d66a8.tar.xz wayland-c13a65fd202d6e7d22e5ea0e334b50135a1d66a8.tar.zst wayland-c13a65fd202d6e7d22e5ea0e334b50135a1d66a8.zip | |
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 <dh.herrmann@googlemail.com>
Diffstat (limited to 'src/wayland-util.c')
| -rw-r--r-- | src/wayland-util.c | 2 |
1 files changed, 2 insertions, 0 deletions
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; } |
