Skip to content
Snippets Groups Projects
Commit ed51e9ae authored by Pekka Paalanen's avatar Pekka Paalanen
Browse files

libweston: fix realloc in weston_idalloc

realloc() does not initialize the added memory, it needs to be zeroed
explicitly.

Not zeroing this memory had one severe consequence: if the new
lowest_free_bucket was 0xffffffff, weston_idalloc_get_id() would fail an
assertion.

Otherwise non-zero bits in the added memory would just cause id numbers
to be skipped unnecessarily, which does no harm.

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/1000



Signed-off-by: default avatarPekka Paalanen <pekka.paalanen@collabora.com>
parent 2733a959
No related branches found
No related tags found
No related merge requests found
......@@ -106,6 +106,8 @@ update_lowest_free_bucket(struct weston_idalloc *idalloc)
weston_assert_uint32_gt(idalloc->compositor, next_num, idalloc->num_buckets);
idalloc->buckets = xrealloc(idalloc->buckets, next_num * sizeof(*idalloc->buckets));
memset(&idalloc->buckets[idalloc->num_buckets], 0,
(next_num - idalloc->num_buckets) * sizeof(*idalloc->buckets));
/* The first one (from the new added) is the lowest free. */
idalloc->lowest_free_bucket = idalloc->num_buckets;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment