From 94fb062ff98ba6eab156493b3ad7ef210d175a79 Mon Sep 17 00:00:00 2001 From: David Shea Date: Thu, 14 Nov 2013 10:50:49 -0500 Subject: [PATCH 03/10] Create local copies of string properties. The string values passed to set_property are owned by the caller, so we need to create new copies of the strings to store in the private data structure. The dispose method already had code to free the private strings, but was missing a check for the en_name property: added one. --- src/tz.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/tz.c b/src/tz.c index c294b44..8d83d0a 100644 --- a/src/tz.c +++ b/src/tz.c @@ -124,16 +124,20 @@ cc_timezone_location_set_property (GObject *object, CcTimezoneLocationPrivate *priv = CC_TIMEZONE_LOCATION (object)->priv; switch (property_id) { case PROP_COUNTRY: - priv->country = g_value_get_string(value); + g_free(priv->country); + priv->country = g_strdup(g_value_get_string(value)); break; case PROP_FULL_COUNTRY: - priv->full_country = g_value_get_string(value); + g_free(priv->full_country); + priv->full_country = g_strdup(g_value_get_string(value)); break; case PROP_EN_NAME: - priv->en_name = g_value_get_string(value); + g_free(priv->en_name); + priv->en_name = g_strdup(g_value_get_string(value)); break; case PROP_STATE: - priv->state = g_value_get_string(value); + g_free(priv->state); + priv->state = g_strdup(g_value_get_string(value)); break; case PROP_LATITUDE: priv->latitude = g_value_get_double(value); @@ -142,10 +146,12 @@ cc_timezone_location_set_property (GObject *object, priv->longitude = g_value_get_double(value); break; case PROP_ZONE: - priv->zone = g_value_get_string(value); + g_strdup(priv->zone); + priv->zone = g_strdup(g_value_get_string(value)); break; case PROP_COMMENT: - priv->comment = g_value_get_string(value); + g_free(priv->comment); + priv->comment = g_strdup(g_value_get_string(value)); break; case PROP_DIST: priv->dist = g_value_get_double(value); @@ -172,6 +178,12 @@ cc_timezone_location_dispose (GObject *object) priv->full_country = NULL; } + if (priv->en_name) + { + g_free (priv->en_name); + priv->en_name = NULL; + } + if (priv->state) { g_free (priv->state); -- 1.8.4.2