summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce Harrington <bryce@osg.samsung.com>2015-12-23 20:53:53 -0800
committerBryce Harrington <bryce@osg.samsung.com>2016-01-12 11:40:38 -0800
commit18e4573cea99fc95aad12b14350bd90c39b9682b (patch)
treef99ba5fa8ae4a85e68edc300068ed3683a8328c7
parent3f650b8c58d9b2815727f412b6e3bc5f444e814e (diff)
downloadweston-18e4573cea99fc95aad12b14350bd90c39b9682b.tar.gz
compositor: Verify that the maximum number of outputs is not exceeded
output_id_pool is defined as a uint32_t, thus ffs() provides a range of 1-32 available id numbers. When the 33rd output is enabled, Weston will set the ID to (unsigned)(-1) and thus lead to some unexpected behaviors. I'm not sure what the best way to handle this error would be since this is in an initialization routine, but at least let's document the potential error condition with an assert().
-rw-r--r--src/compositor.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/compositor.c b/src/compositor.c
index 230fd78d..a2a03a7f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4303,6 +4303,9 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,
{
struct wl_event_loop *loop;
+ /* Verify we haven't reached the limit of 32 available output IDs */
+ assert(ffs(~c->output_id_pool) > 0);
+
output->compositor = c;
output->x = x;
output->y = y;