diff --git a/wayland/buffers.c b/wayland/buffers.c index 227d6d2c0..23bed5552 100644 --- a/wayland/buffers.c +++ b/wayland/buffers.c @@ -94,6 +94,9 @@ static void destroy_buffer(struct buffer *buffer) { if (buffer->surface) { cairo_surface_destroy(buffer->surface); } + if (buffer->pango) { + g_object_unref(buffer->pango); + } memset(buffer, 0, sizeof(struct buffer)); } diff --git a/wayland/pango.c b/wayland/pango.c index 5781541b7..702ab15c0 100644 --- a/wayland/pango.c +++ b/wayland/pango.c @@ -10,12 +10,14 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text, int32_t scale, bool markup) { PangoLayout *layout = pango_cairo_create_layout(cairo); - PangoAttrList *attrs = pango_attr_list_new(); - char *buf = malloc(2048); + PangoAttrList *attrs; if (markup) { + char *buf; pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, NULL); pango_layout_set_markup(layout, buf, -1); + free(buf); } else { + attrs = pango_attr_list_new(); pango_layout_set_text(layout, text, -1); } pango_attr_list_insert(attrs, pango_attr_scale_new(scale)); @@ -25,7 +27,6 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text pango_layout_set_attributes(layout, attrs); pango_attr_list_unref(attrs); pango_font_description_free(desc); - free(buf); return layout; }