aboutsummaryrefslogtreecommitdiffstats
path: root/src/wayland-util.c
diff options
context:
space:
mode:
authorYong Bakos <ybakos@humanoriented.com>2016-09-27 13:03:48 -0500
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2016-10-18 12:24:53 +0300
commite8ad23266f36521215dcd7cfcc524e0ef67d66dd (patch)
tree00d35f79dceb980454e09b7a7235e26115de1174 /src/wayland-util.c
parentutil: Document wl_array (diff)
downloadwayland-e8ad23266f36521215dcd7cfcc524e0ef67d66dd.tar
wayland-e8ad23266f36521215dcd7cfcc524e0ef67d66dd.tar.gz
wayland-e8ad23266f36521215dcd7cfcc524e0ef67d66dd.tar.bz2
wayland-e8ad23266f36521215dcd7cfcc524e0ef67d66dd.tar.lz
wayland-e8ad23266f36521215dcd7cfcc524e0ef67d66dd.tar.xz
wayland-e8ad23266f36521215dcd7cfcc524e0ef67d66dd.tar.zst
wayland-e8ad23266f36521215dcd7cfcc524e0ef67d66dd.zip
wl_array: Set data to invalid address after free
Explicitly set the data member to an invalid memory address during wl_array_release, such that re-using a freed wl_array without re-initializing causes a crash. In addition, this pointer assignment makes wl_array_release testable. Define a constant for the invalid memory address, and add documentation about this behavior, starting at libwayland version 1.13. See https://lists.freedesktop.org/archives/wayland-devel/2016-September/031116.html Signed-off-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> [Pekka: remove the doc about crashing] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'src/wayland-util.c')
-rw-r--r--src/wayland-util.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/wayland-util.c b/src/wayland-util.c
index 639ccf8..077fec7 100644
--- a/src/wayland-util.c
+++ b/src/wayland-util.c
@@ -102,6 +102,7 @@ WL_EXPORT void
wl_array_release(struct wl_array *array)
{
free(array->data);
+ array->data = WL_ARRAY_POISON_PTR;
}
WL_EXPORT void *