summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2014-02-07 09:34:45 +0100
committerKristian Høgsberg <krh@bitplanet.net>2014-02-18 13:49:21 -0800
commit2a67902c8fcdfa317f02998dfbb9966a83913206 (patch)
tree9eb2355c959d93b7276c18403721a44371cf3dd4
parent2c87d9429e3376045c913aaa54aab12a9bf6060e (diff)
noop-renderer: Read the shm buffer contents on attach
The noop-renderer doesn't read buffer contents, which means bad buffers go undetected. Thus, read the buffer contents just for the purpose of triggering SIGBUS (and having the client killed). Fixes the bad-buffer test when run against the headless backend. Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
-rw-r--r--src/noop-renderer.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/noop-renderer.c b/src/noop-renderer.c
index 36d59be6..72332eb7 100644
--- a/src/noop-renderer.c
+++ b/src/noop-renderer.c
@@ -50,6 +50,9 @@ static void
noop_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
{
struct wl_shm_buffer *shm_buffer;
+ uint8_t *data;
+ uint32_t size, i, width, height, stride;
+ volatile unsigned char unused = 0; /* volatile so it's not optimized out */
if (!buffer)
return;
@@ -61,9 +64,24 @@ noop_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
return;
}
+ data = wl_shm_buffer_get_data(shm_buffer);
+ stride = wl_shm_buffer_get_stride(shm_buffer);
+ width = wl_shm_buffer_get_width(shm_buffer);
+ height = wl_shm_buffer_get_height(shm_buffer);
+ size = stride * height;
+
+ /* Access the buffer data to make sure the buffer's client gets killed
+ * if the buffer size is invalid. This makes the bad_buffer test pass.
+ * This can be removed if we start reading the buffer contents
+ * somewhere else, e.g. in repaint_output(). */
+ wl_shm_buffer_begin_access(shm_buffer);
+ for (i = 0; i < size; i++)
+ unused ^= data[i];
+ wl_shm_buffer_end_access(shm_buffer);
+
buffer->shm_buffer = shm_buffer;
- buffer->width = wl_shm_buffer_get_width(shm_buffer);
- buffer->height = wl_shm_buffer_get_height(shm_buffer);
+ buffer->width = width;
+ buffer->height = height;
}
static void