Commit 00577332 authored by Michael Catanzaro's avatar Michael Catanzaro Committed by Michael Catanzaro

bookmark: ensure tags sequence is always created

Somehow we are getting EphyBookmarks objects deserialized without
initializing the tags property. I'm not sure how this happens. It even
happens for JSON corresponding to bookmarks that definitely have tags
set. Anyway, ephy_bookmark_get_tags() is used as if the result is not
nullable, so let's guarantee this and return an empty list instead in
this case.

This is a speculative fix for #612. It should fix the reported crash,
but it's possible it will only uncover a subsequent crash.


(cherry picked from commit 672cffa5)
parent 0f8584ce
......@@ -99,9 +99,10 @@ ephy_bookmark_set_property (GObject *object,
ephy_bookmark_set_url (self, g_value_get_string (value));
break;
case PROP_TAGS:
if (self->tags != NULL)
g_sequence_free (self->tags);
g_sequence_free (self->tags);
self->tags = g_value_get_pointer (value);
if (!self->tags)
self->tags = g_sequence_new (g_free);
break;
case PROP_TYPE:
g_free (self->type);
......@@ -176,8 +177,7 @@ ephy_bookmark_finalize (GObject *object)
g_free (self->title);
g_free (self->id);
if (self->tags)
g_sequence_free (self->tags);
g_sequence_free (self->tags);
G_OBJECT_CLASS (ephy_bookmark_parent_class)->finalize (object);
}
......@@ -279,6 +279,7 @@ ephy_bookmark_class_init (EphyBookmarkClass *klass)
static void
ephy_bookmark_init (EphyBookmark *self)
{
self->tags = g_sequence_new (g_free);
}
EphyBookmark *
......@@ -456,6 +457,7 @@ GSequence *
ephy_bookmark_get_tags (EphyBookmark *self)
{
g_assert (EPHY_IS_BOOKMARK (self));
g_assert (self->tags);
return self->tags;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment