shell: Check for invalid outputs passed on when activating 03/28503/1
authorMarius Vlad <marius.vlad@collabora.com>
Wed, 15 Feb 2023 10:19:42 +0000 (12:19 +0200)
committerMarius Vlad <marius.vlad@collabora.com>
Wed, 15 Feb 2023 15:47:20 +0000 (17:47 +0200)
Connector hot-plugging would generate new wl_output object, which the
client might re-use so rather than blindly trusting the client, make
sure that the output we're getting is really one suitable.

This should avoid getting an incorrect output upon re-plugging in a
connector.

Bug-AGL: SPEC-4705
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I732283fc16841e0e57ddbec5d8bd2333d5028433

src/shell.c

index 640cc73..15f911d 100644 (file)
@@ -1409,10 +1409,20 @@ shell_activate_app(struct wl_client *client,
                   const char *app_id,
                   struct wl_resource *output_res)
 {
-       struct weston_head *head = weston_head_from_resource(output_res);
-       struct weston_output *woutput = weston_head_get_output(head);
-       struct ivi_compositor *ivi = wl_resource_get_user_data(shell_res);
-       struct ivi_output *output = to_ivi_output(woutput);
+       struct weston_head *head;
+       struct weston_output *woutput;
+       struct ivi_compositor *ivi;
+       struct ivi_output *output;
+
+       head = weston_head_from_resource(output_res);
+       if (!head) {
+               weston_log("Invalid output to activate '%s' on\n", app_id);
+               return;
+       }
+
+       woutput = weston_head_get_output(head);
+       ivi = wl_resource_get_user_data(shell_res);
+       output = to_ivi_output(woutput);
 
        if (wl_resource_get_version(shell_res) >=
            AGL_SHELL_BOUND_OK_SINCE_VERSION &&