On 07/10/2014 10:42 AM, Tomasz Bursztyka wrote:
> Hi Daniel,
>
>>> +static void p2p_device_config_result(const char *error,
>>> + DBusMessageIter *iter, void *user_data)
>>> +{
>>> + struct supplicant_p2p_dev_config *config = user_data;
>>> +
>>> + if (error)
>>> + SUPPLICANT_DBG("Unable to set P2P Device configuration");
>>> +
>>> + g_free(config);
>> config was allocated by dbus_malloc0, I think you should use dbus_free()
>> instead of g_free().
>
> Indeed, though in practice it does not really matter, it would be more
> consistent.
You can track the memory allocation with glib and that tracker will
complain loud if allocation/deallocation are not used consistently.
>>> +int
>>> g_supplicant_interface_set_p2p_device_config(GSupplicantInterface
>>> *interface,
>>> + const char *device_name)
>>> +{
>>> + struct supplicant_p2p_dev_config *config;
>>> + int ret;
>>> +
>>> + SUPPLICANT_DBG("P2P Device Name setting %s", device_name);
>>> +
>>> + config = dbus_malloc0(sizeof(*config));
>>> + if (!config)
>>> + return -ENOMEM;
>>> +
>>> + config->device_name = device_name;
>> We are safe here, right? We don't have to strdup device_name?
>
> Actually I first followed that patch with the 26th one. (hostname which
> is gotten from src/utsname.c)
> Maybe it's safer to copy it here yes.
It avoids problems and in most places we do copy all parameters before
calling D-Bus stuff IIRC.
cheers,
daniel
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman