* [PATCH] watch: Free service data in service_reply
@ 2010-07-23 6:01 Zhenhua Zhang
2010-07-23 15:32 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Zhenhua Zhang @ 2010-07-23 6:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 765 bytes --]
Avoid the memory leak of server_data.
---
gdbus/watch.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/gdbus/watch.c b/gdbus/watch.c
index 1d479fa..ccdbb64 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -468,8 +468,10 @@ static void service_reply(DBusPendingCall *call, void *user_data)
dbus_bool_t has_owner;
reply = dbus_pending_call_steal_reply(call);
- if (reply == NULL)
+ if (reply == NULL) {
+ g_free(data);
return;
+ }
dbus_error_init(&error);
@@ -490,6 +492,7 @@ static void service_reply(DBusPendingCall *call, void *user_data)
done:
dbus_message_unref(reply);
+ g_free(data);
}
static void check_service(DBusConnection *connection, const char *name,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] watch: Free service data in service_reply
2010-07-23 6:01 [PATCH] watch: Free service data in service_reply Zhenhua Zhang
@ 2010-07-23 15:32 ` Marcel Holtmann
0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2010-07-23 15:32 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 335 bytes --]
Hi Zhenhua,
> Avoid the memory leak of server_data.
> ---
> gdbus/watch.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
do me a favor and post this to linux-bluetooth(a)vger.kernel.org as well
for the Bluetooth guys to review. After that I can take of applying it
to all trees.
Regards
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] watch: Free service data in service_reply
2010-07-24 9:46 Zhenhua Zhang
@ 2010-07-25 19:52 ` Johan Hedberg
0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2010-07-25 19:52 UTC (permalink / raw)
To: Zhenhua Zhang; +Cc: linux-bluetooth
Hi,
On Sat, Jul 24, 2010, Zhenhua Zhang wrote:
> Avoid the memory leak of server_data.
> ---
> gdbus/watch.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/gdbus/watch.c b/gdbus/watch.c
> index 1d479fa..ccdbb64 100644
> --- a/gdbus/watch.c
> +++ b/gdbus/watch.c
> @@ -468,8 +468,10 @@ static void service_reply(DBusPendingCall *call, void *user_data)
> dbus_bool_t has_owner;
>
> reply = dbus_pending_call_steal_reply(call);
> - if (reply == NULL)
> + if (reply == NULL) {
> + g_free(data);
> return;
> + }
>
> dbus_error_init(&error);
>
> @@ -490,6 +492,7 @@ static void service_reply(DBusPendingCall *call, void *user_data)
>
> done:
> dbus_message_unref(reply);
> + g_free(data);
> }
>
> static void check_service(DBusConnection *connection, const char *name,
Thanks for the patch, but wouldnt't the following be simpler:
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -533,7 +533,7 @@ static void check_service(DBusConnection *connection, const char *name,
goto done;
}
- dbus_pending_call_set_notify(call, service_reply, data, NULL);
+ dbus_pending_call_set_notify(call, service_reply, data, g_free);
dbus_pending_call_unref(call);
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] watch: Free service data in service_reply
@ 2010-07-24 9:46 Zhenhua Zhang
2010-07-25 19:52 ` Johan Hedberg
0 siblings, 1 reply; 4+ messages in thread
From: Zhenhua Zhang @ 2010-07-24 9:46 UTC (permalink / raw)
To: linux-bluetooth
Avoid the memory leak of server_data.
---
gdbus/watch.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/gdbus/watch.c b/gdbus/watch.c
index 1d479fa..ccdbb64 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -468,8 +468,10 @@ static void service_reply(DBusPendingCall *call, void *user_data)
dbus_bool_t has_owner;
reply = dbus_pending_call_steal_reply(call);
- if (reply == NULL)
+ if (reply == NULL) {
+ g_free(data);
return;
+ }
dbus_error_init(&error);
@@ -490,6 +492,7 @@ static void service_reply(DBusPendingCall *call, void *user_data)
done:
dbus_message_unref(reply);
+ g_free(data);
}
static void check_service(DBusConnection *connection, const char *name,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-07-25 19:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-23 6:01 [PATCH] watch: Free service data in service_reply Zhenhua Zhang
2010-07-23 15:32 ` Marcel Holtmann
2010-07-24 9:46 Zhenhua Zhang
2010-07-25 19:52 ` Johan Hedberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.