cairo-util: Don't set title string to Pango layout if the title is NULL

If buttons list isn't empty and title is NULL, SEGV is occured in
pango_layout_set_text(). This patch fixes this problem.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
dev
Tomohito Esaki 6 years ago
parent 651566af2d
commit 6f9db6c4a1
  1. 2
      shared/cairo-util.c

@ -463,10 +463,12 @@ create_layout(cairo_t *cr, const char *title)
PangoFontDescription *desc; PangoFontDescription *desc;
layout = pango_cairo_create_layout(cr); layout = pango_cairo_create_layout(cr);
if (title) {
pango_layout_set_text(layout, title, -1); pango_layout_set_text(layout, title, -1);
desc = pango_font_description_from_string("Sans Bold 10"); desc = pango_font_description_from_string("Sans Bold 10");
pango_layout_set_font_description(layout, desc); pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc); pango_font_description_free(desc);
}
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT); pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
pango_layout_set_auto_dir (layout, FALSE); pango_layout_set_auto_dir (layout, FALSE);

Loading…
Cancel
Save