Commit 25c4198f authored by Simon Kelley's avatar Simon Kelley

Fix use-after-free

parent 4ead40cf
...@@ -91,16 +91,19 @@ static dbus_bool_t add_watch(DBusWatch *watch, void *data) ...@@ -91,16 +91,19 @@ static dbus_bool_t add_watch(DBusWatch *watch, void *data)
static void remove_watch(DBusWatch *watch, void *data) static void remove_watch(DBusWatch *watch, void *data)
{ {
struct watch **up, *w; struct watch **up, *w, *tmp;
for (up = &(daemon->watches), w = daemon->watches; w; w = w->next) for (up = &(daemon->watches), w = daemon->watches; w; w = tmp)
if (w->watch == watch) {
{ tmp = w->next;
*up = w->next; if (w->watch == watch)
free(w); {
} *up = tmp;
else free(w);
up = &(w->next); }
else
up = &(w->next);
}
w = data; /* no warning */ w = data; /* no warning */
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment