From 114d5bfe9d54d1efabc233312d2c23267cf16f59 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 9 Sep 2013 17:12:50 +0200 Subject: layout: Never return NULL from pango_layout_get_text() layouts get initialized with text == NULL as an optimization (avoid a malloc). But pango_layout_set_text (layout, NULL, 0); will set the text to "", so it is impossible to set a NULL text. Fxies crashers in various places that assume NULL return values never happen. https://bugzilla.gnome.org/show_bug.cgi?id=707659 --- pango/pango-layout.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pango/pango-layout.c b/pango/pango-layout.c index cff9c519..2b0147fb 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -1100,6 +1100,11 @@ pango_layout_get_text (PangoLayout *layout) { g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL); + /* We don't ever want to return NULL as the text. + */ + if (G_UNLIKELY (!layout->text)) + return ""; + return layout->text; } -- cgit v1.2.1