From 84355a6d90bd7f5faffb7dec54071beae97a9017 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 20 Oct 2021 08:59:47 +0200 Subject: [PATCH] fodcusadjacenttag: Add selmon->sel guards for tagandviewtoleft/right to prevent segmentation faults ref. #191 --- patch/focusadjacenttag.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/patch/focusadjacenttag.c b/patch/focusadjacenttag.c index 1665c18..85d9d74 100644 --- a/patch/focusadjacenttag.c +++ b/patch/focusadjacenttag.c @@ -63,7 +63,8 @@ viewtoright(const Arg *arg) void tagandviewtoleft(const Arg *arg) { - if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + if (selmon->sel != NULL + && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 && selmon->tagset[selmon->seltags] > 1) { selmon->sel->tags >>= 1; selmon->seltags ^= 1; /* toggle sel tagset */ @@ -83,7 +84,8 @@ tagandviewtoleft(const Arg *arg) void tagandviewtoright(const Arg *arg) { - if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + if (selmon->sel != NULL + && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { selmon->sel->tags <<= 1; selmon->seltags ^= 1; /* toggle sel tagset */