Fix use-after-free with block hotspots

This commit is contained in:
Drew DeVault 2018-04-02 11:53:56 -04:00
parent 0cbd2a4f49
commit c507727ad2
4 changed files with 14 additions and 8 deletions

View file

@ -153,7 +153,7 @@ static uint32_t render_status_block(cairo_t *cairo,
hotspot->width = width;
hotspot->height = height;
hotspot->callback = block_hotspot_callback;
hotspot->destroy = free;
hotspot->destroy = NULL;
hotspot->data = block;
wl_list_insert(&output->hotspots, &hotspot->link);
@ -227,9 +227,9 @@ static uint32_t render_status_line_i3bar(cairo_t *cairo,
struct swaybar_config *config, struct swaybar_output *output,
struct status_line *status, bool focused,
double *x, uint32_t width, uint32_t height) {
struct i3bar_block *block;
uint32_t max_height = 0;
bool edge = true;
struct i3bar_block *block;
wl_list_for_each_reverse(block, &status->blocks, link) {
uint32_t h = render_status_block(cairo, config, output,
block, x, height, focused, edge);
@ -376,6 +376,7 @@ static uint32_t render_workspace_button(cairo_t *cairo,
static uint32_t render_to_cairo(cairo_t *cairo,
struct swaybar *bar, struct swaybar_output *output) {
struct swaybar_config *config = bar->config;
wlr_log(L_DEBUG, "output %p", output);
cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
if (output->focused) {