Skip to content

Commit 3a145a7

Browse files
sc0wraveit65
authored andcommitted
terminal-profile: Fix memory leaks
'g_strconcat' needs to be freed
1 parent 3ff3f27 commit 3a145a7

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

‎src/terminal-profile.c‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,12 @@ terminal_profile_save (TerminalProfile *profile)
849849
TerminalProfilePrivate *priv = profile->priv;
850850
GSettings *changeset;
851851
GSList *l;
852+
gchar *concat;
852853

853854
priv->save_idle_id = 0;
854-
changeset = g_settings_new_with_path (CONF_PROFILE_SCHEMA,
855-
g_strconcat (CONF_PROFILE_PREFIX, priv->profile_dir,"/", NULL));
855+
concat = g_strconcat (CONF_PROFILE_PREFIX, priv->profile_dir,"/", NULL);
856+
changeset = g_settings_new_with_path (CONF_PROFILE_SCHEMA, concat);
857+
g_free (concat);
856858
g_settings_delay (changeset);
857859

858860
for (l = priv->dirty_pspecs; l != NULL; l = l->next)
@@ -955,6 +957,7 @@ terminal_profile_constructor (GType type,
955957
const char *name;
956958
GParamSpec **pspecs;
957959
guint n_pspecs, i;
960+
gchar *concat;
958961

959962
object = G_OBJECT_CLASS (terminal_profile_parent_class)->constructor
960963
(type, n_construct_properties, construct_params);
@@ -965,14 +968,18 @@ terminal_profile_constructor (GType type,
965968
name = g_value_get_string (g_value_array_get_nth (priv->properties, PROP_NAME));
966969
g_assert (name != NULL);
967970

968-
priv->settings = g_settings_new_with_path (CONF_PROFILE_SCHEMA,
969-
g_strconcat (CONF_PROFILE_PREFIX, name, "/", NULL));
971+
concat = g_strconcat (CONF_PROFILE_PREFIX, name, "/", NULL);
972+
priv->settings = g_settings_new_with_path (CONF_PROFILE_SCHEMA, concat);
970973
g_assert (priv->settings != NULL);
974+
g_free (concat);
975+
concat = g_strconcat("changed::", priv->profile_dir, "/", NULL);
971976
g_signal_connect (priv->settings,
972-
g_strconcat("changed::", priv->profile_dir, "/", NULL),
977+
concat,
973978
G_CALLBACK(terminal_profile_gsettings_notify_cb),
974979
profile);
975980

981+
g_free (concat);
982+
976983
/* Now load those properties from GSettings that were not set as construction params */
977984
pspecs = g_object_class_list_properties (G_OBJECT_CLASS (TERMINAL_PROFILE_GET_CLASS (profile)), &n_pspecs);
978985
for (i = 0; i < n_pspecs; ++i)
@@ -1123,16 +1130,20 @@ terminal_profile_set_property (GObject *object,
11231130
g_assert (name != NULL);
11241131
priv->profile_dir = g_strdup (name);
11251132
if (priv->settings != NULL) {
1133+
gchar *concat;
11261134
g_signal_handlers_disconnect_by_func (priv->settings,
11271135
G_CALLBACK(terminal_profile_gsettings_notify_cb),
11281136
profile);
11291137
g_object_unref (priv->settings);
1130-
priv->settings = g_settings_new_with_path (CONF_PROFILE_SCHEMA,
1131-
g_strconcat (CONF_PROFILE_PREFIX, priv->profile_dir, "/", NULL));
1138+
concat= g_strconcat (CONF_PROFILE_PREFIX, priv->profile_dir, "/", NULL);
1139+
priv->settings = g_settings_new_with_path (CONF_PROFILE_SCHEMA, concat);
1140+
g_free (concat);
1141+
concat = g_strconcat("changed::", priv->profile_dir, "/", NULL);
11321142
g_signal_connect (priv->settings,
1133-
g_strconcat("changed::", priv->profile_dir, "/", NULL),
1134-
G_CALLBACK(terminal_profile_gsettings_notify_cb),
1143+
concat,
1144+
G_CALLBACK(terminal_profile_gsettings_notify_cb),
11351145
profile);
1146+
g_free (concat);
11361147
}
11371148
break;
11381149
}

0 commit comments

Comments
 (0)