summaryrefslogtreecommitdiff
path: root/legacy/edbus
diff options
context:
space:
mode:
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>2012-09-21 22:43:58 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-09-21 22:43:58 +0000
commit49ea849059cf4c928cd102a0923702fa69c81fe6 (patch)
treecd18833c965ca6371d9f712e59fc9e1f88e8125e /legacy/edbus
parentd855ad62c92c7bdbbc69a691d2cf02dfbd1208f0 (diff)
edbus: Fix memory leak in
edbus_signal_handler_match_extra_set() And allow values == "" in match_extra_set() Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 77004
Diffstat (limited to 'legacy/edbus')
-rw-r--r--legacy/edbus/src/examples/banshee.c29
-rw-r--r--legacy/edbus/src/lib/edbus_signal_handler.c25
2 files changed, 26 insertions, 28 deletions
diff --git a/legacy/edbus/src/examples/banshee.c b/legacy/edbus/src/examples/banshee.c
index 2134c26028..389962feee 100644
--- a/legacy/edbus/src/examples/banshee.c
+++ b/legacy/edbus/src/examples/banshee.c
@@ -141,11 +141,7 @@ on_name_owner_changed_by_id(void *data, const EDBus_Message *msg)
141 if (!edbus_message_arguments_get(msg, "sss", &bus, &older_id, &new_id)) 141 if (!edbus_message_arguments_get(msg, "sss", &bus, &older_id, &new_id))
142 printf("Error getting arguments from NameOwnerChanged"); 142 printf("Error getting arguments from NameOwnerChanged");
143 143
144 printf("on_name_owner_changed_by_id bus = %s older=%s new=%s\n\n", 144 printf("banshee started on id=%s\n", new_id);
145 bus, older_id, new_id);
146
147 if (!new_id[0])
148 edbus_signal_handler_unref(sh3);
149} 145}
150 146
151static void 147static void
@@ -160,18 +156,6 @@ on_name_owner_changed(void *data, const EDBus_Message *msg)
160 printf("Error getting arguments from NameOwnerChanged"); 156 printf("Error getting arguments from NameOwnerChanged");
161 157
162 printf("bus = %s older=%s new=%s\n\n", bus, older_id, new_id); 158 printf("bus = %s older=%s new=%s\n\n", bus, older_id, new_id);
163
164 if (new_id[0])
165 {
166 sh4 = edbus_signal_handler_add(conn,
167 EDBUS_FDO_BUS,
168 EDBUS_FDO_PATH,
169 EDBUS_FDO_INTERFACE,
170 "NameOwnerChanged",
171 on_name_owner_changed_by_id,
172 NULL);
173 edbus_signal_handler_match_extra_set(sh4, "arg1", new_id, NULL);
174 }
175} 159}
176 160
177int 161int
@@ -276,6 +260,17 @@ main(void)
276 NULL); 260 NULL);
277 edbus_signal_handler_match_extra_set(sh3, "arg0", "org.bansheeproject.Banshee", NULL); 261 edbus_signal_handler_match_extra_set(sh3, "arg0", "org.bansheeproject.Banshee", NULL);
278 262
263 sh4 = edbus_signal_handler_add(conn,
264 EDBUS_FDO_BUS,
265 EDBUS_FDO_PATH,
266 EDBUS_FDO_INTERFACE,
267 "NameOwnerChanged",
268 on_name_owner_changed_by_id,
269 NULL);
270 edbus_signal_handler_match_extra_set(sh4,
271 "arg0", "org.bansheeproject.Banshee",
272 "arg1", "", NULL);
273
279 ecore_timer_add(50, _timer1_cb, NULL); 274 ecore_timer_add(50, _timer1_cb, NULL);
280 275
281 ecore_main_loop_begin(); 276 ecore_main_loop_begin();
diff --git a/legacy/edbus/src/lib/edbus_signal_handler.c b/legacy/edbus/src/lib/edbus_signal_handler.c
index e852ba6569..f5192dbba7 100644
--- a/legacy/edbus/src/lib/edbus_signal_handler.c
+++ b/legacy/edbus/src/lib/edbus_signal_handler.c
@@ -51,7 +51,7 @@ edbus_signal_handler_shutdown(void)
51static void 51static void
52_match_append(Eina_Strbuf *match, const char *key, const char *value) 52_match_append(Eina_Strbuf *match, const char *key, const char *value)
53{ 53{
54 if (value == NULL || !value[0]) return; 54 if (!value) return;
55 55
56 if ((eina_strbuf_length_get(match) + strlen(",=''") + strlen(key) + strlen(value)) 56 if ((eina_strbuf_length_get(match) + strlen(",=''") + strlen(key) + strlen(value))
57 >= DBUS_MAXIMUM_MATCH_RULE_LENGTH) 57 >= DBUS_MAXIMUM_MATCH_RULE_LENGTH)
@@ -79,7 +79,7 @@ EAPI Eina_Bool
79edbus_signal_handler_match_extra_set(EDBus_Signal_Handler *sh, ...) 79edbus_signal_handler_match_extra_set(EDBus_Signal_Handler *sh, ...)
80{ 80{
81 va_list ap; 81 va_list ap;
82 char *key = NULL, *value; 82 char *key = NULL, *read;
83 Signal_Argument *arg; 83 Signal_Argument *arg;
84 DBusError err; 84 DBusError err;
85 85
@@ -91,30 +91,33 @@ edbus_signal_handler_match_extra_set(EDBus_Signal_Handler *sh, ...)
91 EINA_SAFETY_ON_TRUE_RETURN_VAL(dbus_error_is_set(&err), EINA_FALSE); 91 EINA_SAFETY_ON_TRUE_RETURN_VAL(dbus_error_is_set(&err), EINA_FALSE);
92 92
93 va_start(ap, sh); 93 va_start(ap, sh);
94 do 94 for (read = va_arg(ap, char *); read; read = va_arg(ap, char *))
95 { 95 {
96 if (!key) 96 if (!key)
97 { 97 {
98 key = va_arg(ap, char *); 98 key = read;
99 continue; 99 continue;
100 } 100 }
101 value = va_arg(ap, char *);
102 arg = calloc(1, sizeof(Signal_Argument)); 101 arg = calloc(1, sizeof(Signal_Argument));
103 EINA_SAFETY_ON_NULL_GOTO(arg, error); 102 EINA_SAFETY_ON_NULL_GOTO(arg, error);
104
105 if (!strncmp(key, ARGX, strlen(ARGX))) 103 if (!strncmp(key, ARGX, strlen(ARGX)))
106 { 104 {
107 int id = atoi(key+strlen(ARGX)-1); 105 int id = atoi(key + strlen(ARGX));
108 arg->index = (unsigned short)id; 106 arg->index = (unsigned short) id;
109 arg->value = eina_stringshare_add(value); 107 arg->value = eina_stringshare_add(read);
110 sh->args = eina_inlist_sorted_state_insert(sh->args, 108 sh->args = eina_inlist_sorted_state_insert(sh->args,
111 EINA_INLIST_GET(arg), 109 EINA_INLIST_GET(arg),
112 _sort_arg, 110 _sort_arg,
113 sh->state_args); 111 sh->state_args);
114 _match_append(sh->match, key, value); 112 _match_append(sh->match, key, read);
113 }
114 else
115 {
116 ERR("%s not supported", key);
117 free(arg);
115 } 118 }
116 key = NULL; 119 key = NULL;
117 } while(key); 120 }
118 va_end(ap); 121 va_end(ap);
119 122
120 dbus_error_init(&err); 123 dbus_error_init(&err);