[PATCH weston] comp-wayland: use safe foreach when destroying outputs
Pekka Paalanen
ppaalanen at gmail.com
Fri May 23 01:40:32 PDT 2014
On Fri, 23 May 2014 10:03:00 +0300
Pekka Paalanen <ppaalanen at gmail.com> wrote:
> On Wed, 21 May 2014 09:20:02 -0700
> "U. Artie Eoff" <ullysses.a.eoff at intel.com> wrote:
>
> > wl_list_for_each dereference's output to increment the
> > next iteration of the loop. However, output is free'd
> > inside the loop resulting in a dereference to free'd
> > memory.
> >
> > Use wl_list_for_each_safe instead, which is designed to
> > handle this kind of pattern.
> >
> > Signed-off-by: U. Artie Eoff <ullysses.a.eoff at intel.com>
> > ---
> > src/compositor-wayland.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
> > index a08b71a..76e5396 100644
> > --- a/src/compositor-wayland.c
> > +++ b/src/compositor-wayland.c
> > @@ -1997,9 +1997,9 @@ err_free:
> > static void
> > wayland_compositor_destroy(struct wayland_compositor *c)
> > {
> > - struct weston_output *output;
> > + struct weston_output *output, *next;
> >
> > - wl_list_for_each(output, &c->base.output_list, link)
> > + wl_list_for_each_safe(output, next, &c->base.output_list, link)
> > wayland_output_destroy(output);
> >
> > c->base.renderer->destroy(&c->base);
>
> The DRM, x11 and rpi backends do not do this at all. Instead they rely
> on weston_compositor_shutdown() to destroy all outputs and the renderer.
>
> Is there a reason why the wayland backend is different?
On second thought, this is a real fix already, so I have pushed it to
both master and 1.5.
Still, might be nice to have the clean-up in the wayland backend.
$ git push origin stable-1.5:1.5 master:master
Counting objects: 30, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 828 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: tee: hooks/reflog: Permission denied
To ssh://git.freedesktop.org/git/wayland/weston
8801936..a35d028 stable-1.5 -> 1.5
caa7019..a1e887b master -> master
Kristian, what's with the permission denied error there?
The irc announcer worked, and I see both branches got the commit.
Should I consider also the earlier stable branches?
Thanks,
pq
More information about the wayland-devel
mailing list