Fix NULL pointer deref when calc borders and gaps

This commit is contained in:
Alex Kotov 2021-11-16 06:22:32 +05:00
parent 4992ee09c4
commit d794be4c49
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
1 changed files with 12 additions and 6 deletions

View File

@ -20,8 +20,10 @@ centeredmaster(Monitor *m)
}
}
const int gap_size = helpers_gap_size(n, m->sel->isfullscreen);
const int border_width = helpers_border_width(n, m->sel->isfullscreen);
const bool is_fullscreen = m->sel == NULL ? false : m->sel->isfullscreen;
const int gap_size = helpers_gap_size(n, is_fullscreen);
const int border_width = helpers_border_width(n, is_fullscreen);
const int top_left_half_gap = gap_size / 2;
const int bottom_right_half_gap = gap_size - top_left_half_gap;
@ -99,8 +101,10 @@ centeredmaster(Monitor *m)
void
monocle(Monitor *m)
{
const int gap_size = helpers_gap_size(1, m->sel->isfullscreen);
const int border_width = helpers_border_width(1, m->sel->isfullscreen);
const bool is_fullscreen = m->sel == NULL ? false : m->sel->isfullscreen;
const int gap_size = helpers_gap_size(1, is_fullscreen);
const int border_width = helpers_border_width(1, is_fullscreen);
for (Client *c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
resize(
@ -122,8 +126,10 @@ tile(Monitor *m)
for (Client *c = nexttiled(m->clients); c; c = nexttiled(c->next), ++n);
if (n == 0) return;
const int gap_size = helpers_gap_size(n, m->sel->isfullscreen);
const int border_width = helpers_border_width(n, m->sel->isfullscreen);
const bool is_fullscreen = m->sel == NULL ? false : m->sel->isfullscreen;
const int gap_size = helpers_gap_size(n, is_fullscreen);
const int border_width = helpers_border_width(n, is_fullscreen);
const int top_left_half_gap = gap_size / 2;
const int bottom_right_half_gap = gap_size - top_left_half_gap;