mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
src/theme.c: fix misuse of wl_list_for_each
The iterator value of `wl_list_for_each` should never be referenced outside the loop because it points to invalid memory location when the list is empty.
This commit is contained in:
parent
1934d0bf09
commit
5f3600b0b8
1 changed files with 18 additions and 17 deletions
35
src/theme.c
35
src/theme.c
|
|
@ -297,28 +297,29 @@ load_button(struct theme *theme, struct button *b, int active)
|
||||||
buttons[b->type][non_hover_state_set]);
|
buttons[b->type][non_hover_state_set]);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct title_button *leftmost_button = NULL;
|
|
||||||
wl_list_for_each(leftmost_button,
|
|
||||||
&rc.title_buttons_left, link) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
struct title_button *rightmost_button = NULL;
|
|
||||||
wl_list_for_each_reverse(rightmost_button,
|
|
||||||
&rc.title_buttons_right, link) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the loaded button is at the corner of the titlebar, also create
|
* If the loaded button is at the corner of the titlebar, also create
|
||||||
* rounded variants.
|
* rounded variants.
|
||||||
*/
|
*/
|
||||||
uint8_t rounded_state_set = b->state_set | LAB_BS_ROUNDED;
|
uint8_t rounded_state_set = b->state_set | LAB_BS_ROUNDED;
|
||||||
if (leftmost_button && leftmost_button->type == b->type) {
|
|
||||||
create_rounded_buffer(theme, LAB_CORNER_TOP_LEFT,
|
struct title_button *leftmost_button;
|
||||||
&buttons[b->type][rounded_state_set], *buffer);
|
wl_list_for_each(leftmost_button,
|
||||||
} else if (rightmost_button && rightmost_button->type == b->type) {
|
&rc.title_buttons_left, link) {
|
||||||
create_rounded_buffer(theme, LAB_CORNER_TOP_RIGHT,
|
if (leftmost_button->type == b->type) {
|
||||||
&buttons[b->type][rounded_state_set], *buffer);
|
create_rounded_buffer(theme, LAB_CORNER_TOP_LEFT,
|
||||||
|
&buttons[b->type][rounded_state_set], *buffer);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
struct title_button *rightmost_button;
|
||||||
|
wl_list_for_each_reverse(rightmost_button,
|
||||||
|
&rc.title_buttons_right, link) {
|
||||||
|
if (rightmost_button->type == b->type) {
|
||||||
|
create_rounded_buffer(theme, LAB_CORNER_TOP_RIGHT,
|
||||||
|
&buttons[b->type][rounded_state_set], *buffer);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue