[pango] layout: Never return NULL from pango_layout_get_text()
- From: Benjamin Otte <otte src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [pango] layout: Never return NULL from pango_layout_get_text()
 
- Date: Mon,  9 Sep 2013 15:19:11 +0000 (UTC)
 
commit 114d5bfe9d54d1efabc233312d2c23267cf16f59
Author: Benjamin Otte <otte redhat com>
Date:   Mon Sep 9 17:12:50 2013 +0200
    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 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index cff9c51..2b0147f 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;
 }
 
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]