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 | |
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
-rw-r--r-- | common/pango.c | 9 | ||||
-rw-r--r-- | sway/tree/layout.c | 4 | ||||
-rw-r--r-- | swaybar/i3bar.c | 4 | ||||
-rw-r--r-- | swaybar/render.c | 5 |
4 files changed, 14 insertions, 8 deletions
diff --git a/common/pango.c b/common/pango.c index 2ae7883c..658d2876 100644 --- a/common/pango.c +++ b/common/pango.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <stdio.h> | 6 | #include <stdio.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include "log.h" | ||
9 | 10 | ||
10 | PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, | 11 | PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, |
11 | const char *text, int32_t scale, bool markup) { | 12 | const char *text, int32_t scale, bool markup) { |
@@ -13,7 +14,13 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, | |||
13 | PangoAttrList *attrs; | 14 | PangoAttrList *attrs; |
14 | if (markup) { | 15 | if (markup) { |
15 | char *buf; | 16 | char *buf; |
16 | pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, NULL); | 17 | GError *error = NULL; |
18 | if (!sway_assert(pango_parse_markup( | ||
19 | text, -1, 0, &attrs, &buf, NULL, &error), | ||
20 | "pango_parse_markup '%s' -> error %s", text, | ||
21 | error ? error->message : NULL)) { | ||
22 | return NULL; | ||
23 | } | ||
17 | pango_layout_set_markup(layout, buf, -1); | 24 | pango_layout_set_markup(layout, buf, -1); |
18 | free(buf); | 25 | free(buf); |
19 | } else { | 26 | } else { |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index ce0682dc..e8363660 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -248,8 +248,8 @@ void arrange_windows(struct sway_container *container, | |||
248 | struct wlr_box *area = &output->sway_output->usable_area; | 248 | struct wlr_box *area = &output->sway_output->usable_area; |
249 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", | 249 | wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", |
250 | area->width, area->height, area->x, area->y); | 250 | area->width, area->height, area->x, area->y); |
251 | container->width = area->width; | 251 | container->width = width = area->width; |
252 | container->height = area->height; | 252 | container->height = height = area->height; |
253 | container->x = x = area->x; | 253 | container->x = x = area->x; |
254 | container->y = y = area->y; | 254 | container->y = y = area->y; |
255 | wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", | 255 | wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", |
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) { |