aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAleksandr Mezin <mezin.alexander@gmail.com>2022-01-26 19:16:55 +0600
committerSimon Ser <contact@emersion.fr>2022-03-25 09:43:53 +0000
commitae263cca3e848cb2c67a28a690bd5e5d6968faae (patch)
treeeb0224280e0c31288c14d682f71b0b52aba3ce6b /src
parentbuild: use get_variable(pkgconfig) instead of get_pkgconfig_variable() (diff)
downloadwayland-ae263cca3e848cb2c67a28a690bd5e5d6968faae.tar
wayland-ae263cca3e848cb2c67a28a690bd5e5d6968faae.tar.gz
wayland-ae263cca3e848cb2c67a28a690bd5e5d6968faae.tar.bz2
wayland-ae263cca3e848cb2c67a28a690bd5e5d6968faae.tar.lz
wayland-ae263cca3e848cb2c67a28a690bd5e5d6968faae.tar.xz
wayland-ae263cca3e848cb2c67a28a690bd5e5d6968faae.tar.zst
wayland-ae263cca3e848cb2c67a28a690bd5e5d6968faae.zip
util: always check result of wl_array_add()
Not checking the result of wl_array_add() can cause writes past the end of the allocated buffer if realloc fails. Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/wayland-util.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/wayland-util.c b/src/wayland-util.c
index c89a67b..68116bf 100644
--- a/src/wayland-util.c
+++ b/src/wayland-util.c
@@ -241,8 +241,10 @@ wl_map_insert_at(struct wl_map *map, uint32_t flags, uint32_t i, void *data)
if (count < i)
return -1;
- if (count == i)
- wl_array_add(entries, sizeof *start);
+ if (count == i) {
+ if (!wl_array_add(entries, sizeof *start))
+ return -1;
+ }
start = entries->data;
start[i].data = data;
@@ -277,7 +279,9 @@ wl_map_reserve_new(struct wl_map *map, uint32_t i)
return -1;
if (count == i) {
- wl_array_add(entries, sizeof *start);
+ if (!wl_array_add(entries, sizeof *start))
+ return -1;
+
start = entries->data;
start[i].data = NULL;
} else {