summaryrefslogtreecommitdiff
path: root/gdata/gdata-entry.c
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2019-07-23 12:51:52 +0200
committerOndrej Holy <oholy@redhat.com>2019-07-23 12:51:52 +0200
commit7229cdabff7e9b4e2174b2de0669957665de63f0 (patch)
tree343b32d1dc8fe5ed0d74db2fcb0f8aacb8f710f7 /gdata/gdata-entry.c
parent5d318e0bf905d0f1a8b3fe1e47ee7847739082e3 (diff)
downloadlibgdata-7229cdabff7e9b4e2174b2de0669957665de63f0.tar.gz
core: Don't always free the current id string in gdata_entry_get_id()
Currently, if you call gdata_entry_get_id() for the second time, the first returned id string is released even if the id hasn't been changed. This is unexpected and causes issues in several places of gvfsbackendgoogle.c, where g_strdup() has to be used as a workaround to prevent segfaults. Let's change the behavior to not free the current id, if it was not changed. Closes: https://gitlab.gnome.org/GNOME/libgdata/issues/31
Diffstat (limited to 'gdata/gdata-entry.c')
-rw-r--r--gdata/gdata-entry.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gdata/gdata-entry.c b/gdata/gdata-entry.c
index 2d84bc63..4a4f35a5 100644
--- a/gdata/gdata-entry.c
+++ b/gdata/gdata-entry.c
@@ -787,11 +787,14 @@ gdata_entry_get_id (GDataEntry *self)
/* We have to get the actual property since GDataDocumentsEntry overrides it. We then store it in our own ID field so that we can
* free it later on. */
g_object_get (G_OBJECT (self), "id", &id, NULL);
+ if (g_strcmp0 (id, self->priv->id) != 0) {
+ g_free (self->priv->id);
+ self->priv->id = id;
+ } else {
+ g_free (id);
+ }
- g_free (self->priv->id);
- self->priv->id = id;
-
- return id;
+ return self->priv->id;
}
/**