aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-02-21 08:06:35 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-02-25 17:10:04 -0500
commitdca6c2ad8f1d344981eec842e5cba588c867966b (patch)
tree4f8fcdcfaaa5d1a3b6abdd951337290cec780486
parentrun_as_ipc_client: free response after running the IPC command (diff)
downloadsway-dca6c2ad8f1d344981eec842e5cba588c867966b.tar.gz
sway-dca6c2ad8f1d344981eec842e5cba588c867966b.tar.zst
sway-dca6c2ad8f1d344981eec842e5cba588c867966b.zip
output_get_active_workspace: check workspaces length
If an output's node was dirty and the transaction was committed before a workspace was moved to or created for the output, the instruction would have a bad value for `state->active_workspace` due to a missing length check in `output_get_active_workspace`. If there was no focus on the output, the first workspace was being returned. If the workspace list was currently empty, the value was either garbage, or in the case of an output being disabled and re-enabled, a workspace that may have been previously freed. This just adds the length check to avoid returning out of bounds value.
-rw-r--r--sway/desktop/output.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index c5461ee6..61beb7af 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -320,6 +320,9 @@ struct sway_workspace *output_get_active_workspace(struct sway_output *output) {
320 struct sway_seat *seat = input_manager_current_seat(); 320 struct sway_seat *seat = input_manager_current_seat();
321 struct sway_node *focus = seat_get_active_tiling_child(seat, &output->node); 321 struct sway_node *focus = seat_get_active_tiling_child(seat, &output->node);
322 if (!focus) { 322 if (!focus) {
323 if (!output->workspaces->length) {
324 return NULL;
325 }
323 return output->workspaces->items[0]; 326 return output->workspaces->items[0];
324 } 327 }
325 return focus->sway_workspace; 328 return focus->sway_workspace;