fodcusadjacenttag: Add selmon->sel guards for tagandviewtoleft/right to prevent segmentation faults ref. #191

This commit is contained in:
bakkeby 2021-10-20 08:59:47 +02:00
parent ce270a320e
commit 84355a6d90

View File

@ -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 */