[PATCH wayland 2/4] wl_array: Set data to null after free

Yong Bakos junk at humanoriented.com
Fri Sep 16 22:37:37 UTC 2016


From: Yong Bakos <ybakos at humanoriented.com>

Explicitly set the data member to NULL during wl_array_release, preventing the
dangling pointer but, more importantly, making it testable.

Signed-off-by: Yong Bakos <ybakos at humanoriented.com>
---
 src/wayland-util.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/wayland-util.c b/src/wayland-util.c
index 639ccf8..2efb133 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 = NULL;
 }
 
 WL_EXPORT void *
-- 
2.7.2



More information about the wayland-devel mailing list