Skip to content

Write all fields of boxes when no output present

bi4k8 requested to merge bi4k8/wlroots:fully-init-out-boxes into master

Several functions write to wlr_box output arguments, but do not write to their x/y coordinates when setting the boxes to empty. Unfortunately, the callers still access their x and y fields afterward, expecting them to be initialized.

For example, wlr_output_layout_output_in_direction expects wlr_output_layout_get_box to fully initialize its box argument and reads ref_box.x subsequently.

wlr_cursor_map_to_region and wlr_cursor_map_input_to_region manage to avoid actual undefined behavior here by handling the wlr_box_empty(box) case specially, but it's much clearer and safer for functions to not conditionally partially initialize their output arguments.

Also found with clang --analyze.

Merge request reports