diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-04-02 11:53:56 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-04-02 11:53:56 -0400 |
commit | c507727ad240b978c6e09e3aa9238080ca9a1c81 (patch) | |
tree | 2ef131d4798845e972b3350fa816cc2ea0bca8e1 /swaybar | |
parent | Send click events for i3bar blocks (diff) | |
download | sway-c507727ad240b978c6e09e3aa9238080ca9a1c81.tar.gz sway-c507727ad240b978c6e09e3aa9238080ca9a1c81.tar.zst sway-c507727ad240b978c6e09e3aa9238080ca9a1c81.zip |
Fix use-after-free with block hotspots
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/i3bar.c | 4 | ||||
-rw-r--r-- | swaybar/render.c | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c index 5e98c4aa..46459e24 100644 --- a/swaybar/i3bar.c +++ b/swaybar/i3bar.c | |||
@@ -30,9 +30,7 @@ static bool i3bar_parse_json(struct status_line *status, const char *text) { | |||
30 | status_error(status, "[failed to parse i3bar json]"); | 30 | status_error(status, "[failed to parse i3bar json]"); |
31 | return false; | 31 | return false; |
32 | } | 32 | } |
33 | if (json_object_array_length(results) < 1) { | 33 | wlr_log(L_DEBUG, "Got i3bar json: '%s'", text); |
34 | return true; | ||
35 | } | ||
36 | for (size_t i = 0; i < json_object_array_length(results); ++i) { | 34 | for (size_t i = 0; i < json_object_array_length(results); ++i) { |
37 | json_object *full_text, *short_text, *color, *min_width, *align, *urgent; | 35 | json_object *full_text, *short_text, *color, *min_width, *align, *urgent; |
38 | json_object *name, *instance, *separator, *separator_block_width; | 36 | json_object *name, *instance, *separator, *separator_block_width; |
diff --git a/swaybar/render.c b/swaybar/render.c index a5039a2e..a62e1d01 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -153,7 +153,7 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
153 | hotspot->width = width; | 153 | hotspot->width = width; |
154 | hotspot->height = height; | 154 | hotspot->height = height; |
155 | hotspot->callback = block_hotspot_callback; | 155 | hotspot->callback = block_hotspot_callback; |
156 | hotspot->destroy = free; | 156 | hotspot->destroy = NULL; |
157 | hotspot->data = block; | 157 | hotspot->data = block; |
158 | wl_list_insert(&output->hotspots, &hotspot->link); | 158 | wl_list_insert(&output->hotspots, &hotspot->link); |
159 | 159 | ||
@@ -227,9 +227,9 @@ static uint32_t render_status_line_i3bar(cairo_t *cairo, | |||
227 | struct swaybar_config *config, struct swaybar_output *output, | 227 | struct swaybar_config *config, struct swaybar_output *output, |
228 | struct status_line *status, bool focused, | 228 | struct status_line *status, bool focused, |
229 | double *x, uint32_t width, uint32_t height) { | 229 | double *x, uint32_t width, uint32_t height) { |
230 | struct i3bar_block *block; | ||
231 | uint32_t max_height = 0; | 230 | uint32_t max_height = 0; |
232 | bool edge = true; | 231 | bool edge = true; |
232 | struct i3bar_block *block; | ||
233 | wl_list_for_each_reverse(block, &status->blocks, link) { | 233 | wl_list_for_each_reverse(block, &status->blocks, link) { |
234 | uint32_t h = render_status_block(cairo, config, output, | 234 | uint32_t h = render_status_block(cairo, config, output, |
235 | block, x, height, focused, edge); | 235 | block, x, height, focused, edge); |
@@ -376,6 +376,7 @@ static uint32_t render_workspace_button(cairo_t *cairo, | |||
376 | static uint32_t render_to_cairo(cairo_t *cairo, | 376 | static uint32_t render_to_cairo(cairo_t *cairo, |
377 | struct swaybar *bar, struct swaybar_output *output) { | 377 | struct swaybar *bar, struct swaybar_output *output) { |
378 | struct swaybar_config *config = bar->config; | 378 | struct swaybar_config *config = bar->config; |
379 | wlr_log(L_DEBUG, "output %p", output); | ||
379 | 380 | ||
380 | cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); | 381 | cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); |
381 | if (output->focused) { | 382 | if (output->focused) { |