Re: [RFC] adapter: Fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrei,

On Fri, May 15, 2015, Andrei Emeltchenko wrote:
> In case of error with dbus stuff free allocated memory and set filter
> to NULL.
> ---
>  src/adapter.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/adapter.c b/src/adapter.c
> index 8ee5b5b..7035a69 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -2219,8 +2219,11 @@ static bool parse_discovery_filter_dict(struct discovery_filter **filter,
>  
>  	dbus_message_iter_init(msg, &iter);
>  	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
> -	    dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_DICT_ENTRY)
> +	    dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_DICT_ENTRY) {
> +		g_free(*filter);
> +		*filter = NULL;
>  		return false;
> +	}

Good catch, but I think 'goto invalid_args;' would be a cleaner thing to
do. The extra g_slise_free_full call is fine since NULL is the same as
an empty list.

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux