mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-05 13:29:50 -05:00
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>
This commit is contained in:
parent
b6bbc0c44d
commit
ae263cca3e
1 changed files with 7 additions and 3 deletions
|
|
@ -241,8 +241,10 @@ wl_map_insert_at(struct wl_map *map, uint32_t flags, uint32_t i, void *data)
|
||||||
if (count < i)
|
if (count < i)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (count == i)
|
if (count == i) {
|
||||||
wl_array_add(entries, sizeof *start);
|
if (!wl_array_add(entries, sizeof *start))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
start = entries->data;
|
start = entries->data;
|
||||||
start[i].data = data;
|
start[i].data = data;
|
||||||
|
|
@ -277,7 +279,9 @@ wl_map_reserve_new(struct wl_map *map, uint32_t i)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (count == i) {
|
if (count == i) {
|
||||||
wl_array_add(entries, sizeof *start);
|
if (!wl_array_add(entries, sizeof *start))
|
||||||
|
return -1;
|
||||||
|
|
||||||
start = entries->data;
|
start = entries->data;
|
||||||
start[i].data = NULL;
|
start[i].data = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue