Fix segfault on bookmark completion (#189).
authorDaniel Carl <danielcarl@gmx.de>
Tue, 10 Mar 2015 20:41:11 +0000 (21:41 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Tue, 10 Mar 2015 20:44:09 +0000 (21:44 +0100)
If the bookmark file contained lines without any tab char, the completion
caused a segfault.

src/bookmark.c

index 218daec..8c8ea2d 100644 (file)
@@ -317,10 +317,10 @@ static Bookmark *line_to_bookmark(const char *uri, const char *data)
     char *p;
     Bookmark *bm;
 
-    /* data part may consist of title or title<tab>tags*/
+    /* data part may consist of title or title<tab>tags */
     bm      = g_slice_new(Bookmark);
     bm->uri = g_strdup(uri);
-    if ((p = strchr(data, '\t'))) {
+    if (data && (p = strchr(data, '\t'))) {
         *p        = '\0';
         bm->title = g_strdup(data);
         bm->tags  = g_strdup(p + 1);