[PATCH] util: clear pointers on wl_list_remove()
Pekka Paalanen
ppaalanen at gmail.com
Fri Nov 11 00:33:28 PST 2011
Set the next and prev pointers of the removed list element to NULL. This
will catch programming errors that would use invalid list pointers,
double-remove for instance.
Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
The downside is, someone might get the idea of checking if an element
is part of any list by comparing prev or next to NULL. Maybe we should
use (void *)16 instead of NULL, or something?
src/wayland-util.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/wayland-util.c b/src/wayland-util.c
index 0dae01b..6e9c797 100644
--- a/src/wayland-util.c
+++ b/src/wayland-util.c
@@ -46,6 +46,8 @@ wl_list_remove(struct wl_list *elm)
{
elm->prev->next = elm->next;
elm->next->prev = elm->prev;
+ elm->next = NULL;
+ elm->prev = NULL;
}
WL_EXPORT int
--
1.7.3.4
More information about the wayland-devel
mailing list