diff options
author | Emmanuele Bassi <ebassi@linux.intel.com> | 2010-11-14 15:23:36 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@linux.intel.com> | 2010-11-29 19:00:00 +0000 |
commit | 5dc3dbcccb822924fc2938a25ed7320a20851da7 (patch) | |
tree | 8f4b464e341f6f4fe1c72201aa1ee30c17df98f1 | |
parent | 8a6ac9afcbc77cc0dcba8bc363a364077860a187 (diff) | |
download | clutter-5dc3dbcccb822924fc2938a25ed7320a20851da7.tar.gz |
text: Do not segfault with NULL :font-name
Make sure that we have a fall back in place for the default font name
string, and use g_strcmp0 to protect ourselves from NULL strings.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2417
(cherry picked from commit e6bc65b5c37c38dbf5a82dea724e2f389e2b481e)
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
-rw-r--r-- | clutter/clutter-text.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index f9b52fdec..5fe34d74b 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -3855,13 +3855,21 @@ clutter_text_set_font_name (ClutterText *self, g_return_if_fail (CLUTTER_IS_TEXT (self)); /* get the default font name from the backend */ - if (!font_name || font_name[0] == '\0') + if (font_name == NULL || font_name[0] == '\0') { ClutterSettings *settings = clutter_settings_get_default (); gchar *default_font_name = NULL; - g_object_get (settings, "font-name", default_font_name, NULL); - font_name = default_font_name; + g_object_get (settings, "font-name", &default_font_name, NULL); + + if (default_font_name != NULL) + font_name = default_font_name; + else + { + /* last fallback */ + default_font_name = g_strdup ("Sans 12"); + } + is_default_font = TRUE; } else @@ -3869,7 +3877,7 @@ clutter_text_set_font_name (ClutterText *self, priv = self->priv; - if (priv->font_name && strcmp (priv->font_name, font_name) == 0) + if (g_strcmp0 (priv->font_name, font_name) == 0) goto out; desc = pango_font_description_from_string (font_name); |