]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Check the return value of wlr_output_layout_get() for NULL
authorJohn Lindgren <john@jlindgren.net>
Fri, 24 Dec 2021 20:53:49 +0000 (15:53 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 24 Dec 2021 21:08:32 +0000 (21:08 +0000)
wlr_output_layout_get() seems to return NULL for disabled outputs.

Fixes: #174
src/output.c
src/view.c

index aa1a8209128bb1c798edb4e668c1b75d4dc9639c..3f97402c881eb9029dd3e2586695dec3e2b7e1f8 100644 (file)
@@ -526,6 +526,10 @@ render_osd(struct output *output, pixman_region32_t *damage,
        struct wlr_output_layout_output *ol_output;
        wl_list_for_each(o, &server->outputs, link) {
                ol_output = wlr_output_layout_get(layout, o->wlr_output);
+               if (!ol_output) {
+                       continue;
+               }
+
                struct wlr_box box = {
                        .x = ol_output->x + o->wlr_output->width
                                / o->wlr_output->scale / 2,
index 738a08bf0f8ada9af32bc0949ff81cff492c4820..8675d0730115f4bcde68392e29324bc7547c0c5a 100644 (file)
@@ -125,6 +125,10 @@ view_center(struct view *view)
        struct wlr_output_layout *layout = view->server->output_layout;
        struct wlr_output_layout_output *ol_output =
                wlr_output_layout_get(layout, wlr_output);
+       if (!ol_output) {
+               return;
+       }
+
        int center_x = ol_output->x + wlr_output->width / wlr_output->scale / 2;
        int center_y = ol_output->y + wlr_output->height / wlr_output->scale / 2;
        view_move(view, center_x - view->w / 2, center_y - view->h / 2);