From ceb556178d59d6e06871b1b921e5c8b9be084582 Mon Sep 17 00:00:00 2001 From: Matthew Daley Date: Wed, 11 Sep 2013 02:34:17 +1200 Subject: libxl: fix use-after-free in discard_events iteration We need to use the foreach variant which gets the next pointer before the loop body is executed. Coverity-ID: 1056193 Signed-off-by: Matthew Daley Acked-by: Ian Jackson --- tools/libxl/libxl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 7a7aaf90fe..0879f2331f 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -122,8 +122,8 @@ static void free_disable_deaths(libxl__gc *gc, static void discard_events(struct libxl__event_list *l) { /* doesn't bother unlinking from the list, so l is corrupt on return */ - libxl_event *ev; - LIBXL_TAILQ_FOREACH(ev, l, link) + libxl_event *ev, *next; + LIBXL_TAILQ_FOREACH_SAFE(ev, l, link, next) libxl_event_free(0, ev); } -- cgit v1.2.3