rpi: avoid segfault in rpir_view_compute_rects() when EGL client destroys buffer
authorJohn Sadler <deathofathousandpapercuts@gmail.com>
Sat, 5 Sep 2015 14:01:39 +0000 (15:01 +0100)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Tue, 8 Sep 2015 13:21:45 +0000 (16:21 +0300)
This commit works-around a serious issue when running with the RPi backend.
When an EGL client shuts down and destroys it's EGL window, Weston dies with
a segmentation fault in the above function (because `buffer` is now NULL).

The addition of a simple NULL check avoids the problem.

This is a minor re-formatting of the patch already submitted here:

  http://patchwork.freedesktop.org/patch/34885

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85167

Signed-off-by: John Sadler <deathofathousandpapercuts@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
src/rpi-renderer.c

index a096033..d0a9797 100644 (file)
@@ -703,6 +703,9 @@ rpir_view_compute_rects(struct rpir_view *view,
                struct weston_buffer *buffer =
                        view->surface->egl_front->buffer_ref.buffer;
 
+               if (!buffer)
+                       return -1;
+
                src_width = buffer->width << 16;
                src_height = buffer->height << 16;
        } else {