linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Zhenhua Zhang <zhenhua.zhang@intel.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] watch: Free service data in service_reply
Date: Sun, 25 Jul 2010 22:52:50 +0300	[thread overview]
Message-ID: <20100725195250.GA17003@jh-x301> (raw)
In-Reply-To: <1279964787-3989-1-git-send-email-zhenhua.zhang@intel.com>

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

      reply	other threads:[~2010-07-25 19:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-24  9:46 [PATCH] watch: Free service data in service_reply Zhenhua Zhang
2010-07-25 19:52 ` Johan Hedberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100725195250.GA17003@jh-x301 \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=zhenhua.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).