aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2018-06-30 22:39:37 +0900
committerDominique Martinet <asmadeus@codewreck.org>2018-07-02 08:03:41 +0900
commit9c9ee3e4ef9d4e57ec801a79e0b2da1bd2a6d46e (patch)
tree9156cb10cbc718735ff70571a44a8ca1f457dd46
parentab187405297b77f85e0d5ed9630ae43b2db61324 (diff)
find prev/next output/workspace: add NULL check
These could be called with NULL if there is no focus Found through static analysis.
-rw-r--r--sway/tree/workspace.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 5eb4be0f..3a311cd1 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -271,6 +271,9 @@ struct sway_container *workspace_by_name(const char *name) {
*/
struct sway_container *workspace_output_prev_next_impl(
struct sway_container *output, bool next) {
+ if (!output) {
+ return NULL;
+ }
if (!sway_assert(output->type == C_OUTPUT,
"Argument must be an output, is %d", output->type)) {
return NULL;
@@ -303,6 +306,9 @@ struct sway_container *workspace_output_prev_next_impl(
*/
struct sway_container *workspace_prev_next_impl(
struct sway_container *workspace, bool next) {
+ if (!workspace) {
+ return NULL;
+ }
if (!sway_assert(workspace->type == C_WORKSPACE,
"Argument must be a workspace, is %d", workspace->type)) {
return NULL;