[gnome-documents/gnome-3-12] places-bookmarks: Don't crash if page has no text



commit ecd5b70c0eec08cc0b75d21e412086d09a9fe84f
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Oct 6 19:02:42 2014 +0200

    places-bookmarks: Don't crash if page has no text
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738015

 src/lib/gd-places-bookmarks.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/lib/gd-places-bookmarks.c b/src/lib/gd-places-bookmarks.c
index 1a513d1..6348e62 100644
--- a/src/lib/gd-places-bookmarks.c
+++ b/src/lib/gd-places-bookmarks.c
@@ -178,7 +178,7 @@ get_pretty_name (const char *text)
 {
         char *name = NULL;
         char *trimmed;
-        char *basename;
+        char *basename = NULL;
         int i;
         int last_word = -1;
         int last_sentence = -1;
@@ -213,6 +213,11 @@ get_pretty_name (const char *text)
                 i = last_word;
         }
 
+        if (i == -1) {
+                name = NULL;
+                goto out;
+        }
+
         basename = g_utf8_substring (trimmed, 0, i);
         if (ellipse) {
                 name = g_strdup_printf ("“%s…”", basename);
@@ -220,6 +225,7 @@ get_pretty_name (const char *text)
                 name = g_strdup_printf ("“%s”", basename);
         }
 
+ out:
         g_free (basename);
         g_free (trimmed);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]