Merge lp:~charlesk/indicator-sound/blacklist-leaks into lp:indicator-sound/fifth

Proposed by Charles Kerr
Status: Merged
Approved by: Charles Kerr
Approved revision: 312
Merged at revision: 315
Proposed branch: lp:~charlesk/indicator-sound/blacklist-leaks
Merge into: lp:indicator-sound/fifth
Diff against target: 57 lines (+8/-8)
1 file modified
src/sound-service-dbus.c (+8/-8)
To merge this branch: bzr merge lp:~charlesk/indicator-sound/blacklist-leaks
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+98024@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

g_variant_get("(s)") gets a newly-allocated string
g_variant_get("(&s)") peeks the variant's internal pointer to be treated as const

We were doing the former and leaking the string; this patch uses the latter and adds const

Revision history for this message
Conor Curran (cjcurran) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/sound-service-dbus.c'
2--- src/sound-service-dbus.c 2012-03-16 11:07:29 +0000
3+++ src/sound-service-dbus.c 2012-03-16 23:23:20 +0000
4@@ -82,11 +82,11 @@
5 static void show_sound_settings_dialog (DbusmenuMenuitem *mi,
6 gpointer user_data);
7 static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self,
8- gchar* player_name,
9+ const gchar* player_name,
10 gboolean blacklist);
11
12 static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus* self,
13- gchar* player_name);
14+ const gchar* player_name);
15
16 G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT);
17
18@@ -315,8 +315,8 @@
19 }
20 else if (g_strcmp0(method, "BlacklistMediaPlayer") == 0) {
21 gboolean blacklist;
22- gchar* player_name;
23- g_variant_get (params, "(sb)", &player_name, &blacklist);
24+ const gchar* player_name;
25+ g_variant_get (params, "(&sb)", &player_name, &blacklist);
26
27 g_debug ("BlacklistMediaPlayer - bool %i", blacklist);
28 g_debug ("BlacklistMediaPlayer - name %s", player_name);
29@@ -326,8 +326,8 @@
30 retval = g_variant_new ("(b)", result);
31 }
32 else if (g_strcmp0(method, "IsBlacklisted") == 0) {
33- gchar* player_name;
34- g_variant_get (params, "(s)", &player_name);
35+ const gchar* player_name;
36+ g_variant_get (params, "(&s)", &player_name);
37
38 g_debug ("IsBlacklisted - name %s", player_name);
39 gboolean result = sound_service_dbus_is_blacklisted (service,
40@@ -374,7 +374,7 @@
41 TODO - Works nicely but refactor into at least two different methods
42 **/
43 static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self,
44- gchar* player_name,
45+ const gchar* player_name,
46 gboolean blacklist)
47 {
48 g_return_val_if_fail (player_name != NULL, FALSE);
49@@ -457,7 +457,7 @@
50 }
51
52 static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus *self,
53- gchar *player_name)
54+ const gchar *player_name)
55 {
56 GSettings *our_settings;
57 GVariant *the_black_list;

Subscribers

People subscribed via source and target branches