summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2013-09-09 17:12:50 +0200
committerBenjamin Otte <otte@redhat.com>2013-09-09 17:12:50 +0200
commit114d5bfe9d54d1efabc233312d2c23267cf16f59 (patch)
tree055b5cec8b2edf61ed9e051096144c09c11e0909
parent285be5bd7ee3ce87bb027b405be674d6f91995d1 (diff)
downloadpango-114d5bfe9d54d1efabc233312d2c23267cf16f59.tar.gz
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
-rw-r--r--pango/pango-layout.c5
1 files changed, 5 insertions, 0 deletions
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;
}