Skip to content

Commit

Permalink
[dbus] Fix free() vs g_free() issues
Browse files Browse the repository at this point in the history
The get_hidden_modes() returns data allocated via g_key_file_get_string()
which should be released with g_free() and fallback uses strdup() which
should use free().

Use g_strdup() in the fallback case and release memory with g_free().

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Jul 7, 2016
1 parent 2abea95 commit ddc2942
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/usb_moded-dbus.c
Expand Up @@ -248,10 +248,10 @@ static DBusHandlerResult msg_handler(DBusConnection *const connection, DBusMessa
{
char *config = get_hidden_modes();
if(!config)
config = strdup("");
config = g_strdup("");
if((reply = dbus_message_new_method_return(msg)))
dbus_message_append_args (reply, DBUS_TYPE_STRING, &config, DBUS_TYPE_INVALID);
free(config);
g_free(config);
}
else if(!strcmp(member, USB_MODE_NETWORK_SET))
{
Expand Down

0 comments on commit ddc2942

Please sign in to comment.