Skip to content

Commit

Permalink
[network] Remove erronous use of const, fix potential memory leak
Browse files Browse the repository at this point in the history
Using const wrongly, removing to make code more readable and sensible.
Also we do not want to leak the wifi service when connection to internet
sharing mode.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Nov 4, 2014
1 parent 5842e28 commit 04b9cff
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/usb_moded-network.c
Expand Up @@ -391,7 +391,7 @@ static int write_udhcpd_conf(struct ipforward_data *ipforward, struct mode_list_
/**
* Connman message handling
*/
static const char * connman_parse_manager_reply(DBusMessage *reply, const char *req_service)
static char * connman_parse_manager_reply(DBusMessage *reply, const char *req_service)
{
DBusMessageIter iter, subiter, origiter;
int type;
Expand Down Expand Up @@ -550,7 +550,7 @@ static int connman_set_cellular_online(DBusConnection *dbus_conn_connman, const
DBusMessage *msg = NULL, *reply;
DBusError error;
int ret = 0;
const char *wifi = NULL;
char *wifi = NULL;

dbus_error_init(&error);

Expand Down Expand Up @@ -589,6 +589,9 @@ static int connman_set_cellular_online(DBusConnection *dbus_conn_connman, const
dbus_message_unref(msg);
}

if(wifi)
free(wifi);

return(ret);
}

Expand Down Expand Up @@ -664,7 +667,7 @@ static int connman_get_connection_data(struct ipforward_data *ipforward)
DBusConnection *dbus_conn_connman = NULL;
DBusMessage *msg = NULL, *reply = NULL;
DBusError error;
const char *service = NULL;
char *service = NULL;
int online = 0, ret = 0;

dbus_error_init(&error);
Expand Down Expand Up @@ -716,7 +719,7 @@ static int connman_get_connection_data(struct ipforward_data *ipforward)
}
dbus_connection_unref(dbus_conn_connman);
dbus_error_free(&error);
free((char *)service);
free(service);
return(ret);
}

Expand Down

0 comments on commit 04b9cff

Please sign in to comment.