[PATCH v2 wayland 3/3] shm: wl_shm_buffer_get_data() requires a valid pool.

Derek Foreman derekf at osg.samsung.com
Thu Nov 5 11:57:47 PST 2015


There's no situation where a shm buffer without a pool makes sense,
so we enforce the pool's existence a little more rigidly.

Acked-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 src/wayland-shm.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index db23909..0cd8c11 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -353,10 +353,12 @@ wl_shm_buffer_get_stride(struct wl_shm_buffer *buffer)
 WL_EXPORT void *
 wl_shm_buffer_get_data(struct wl_shm_buffer *buffer)
 {
-	if (buffer->pool)
-		return buffer->pool->data + buffer->offset;
-	else
-		return buffer + 1;
+	assert(buffer->pool);
+
+	if (!buffer->pool)
+		return NULL;
+
+	return buffer->pool->data + buffer->offset;
 }
 
 WL_EXPORT uint32_t
-- 
2.6.1



More information about the wayland-devel mailing list