respondd-module-wifi: free json_object by json_object_put
This commit is contained in:
parent
8247f333e4
commit
0376376945
|
@ -13,10 +13,8 @@ static int station_neighbours_handler(struct nl_msg *msg, void *arg) {
|
||||||
struct json_object *neighbour, *json = (struct json_object *) arg;
|
struct json_object *neighbour, *json = (struct json_object *) arg;
|
||||||
|
|
||||||
neighbour = json_object_new_object();
|
neighbour = json_object_new_object();
|
||||||
if (!neighbour) {
|
if (!neighbour)
|
||||||
//TODO why needed? : json_object_put(result);
|
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
|
||||||
|
|
||||||
struct nlattr *tb[NL80211_ATTR_MAX + 1];
|
struct nlattr *tb[NL80211_ATTR_MAX + 1];
|
||||||
|
|
||||||
|
@ -27,13 +25,16 @@ static int station_neighbours_handler(struct nl_msg *msg, void *arg) {
|
||||||
|
|
||||||
if (!station_info) {
|
if (!station_info) {
|
||||||
fputs("respondd-module-wifi: station data missing in netlink message\n", stderr);
|
fputs("respondd-module-wifi: station data missing in netlink message\n", stderr);
|
||||||
|
json_object_put(neighbour);
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
char mac_addr[20];
|
char mac_addr[20];
|
||||||
|
|
||||||
if (!tb[NL80211_ATTR_MAC])
|
if (!tb[NL80211_ATTR_MAC]) {
|
||||||
|
json_object_put(neighbour);
|
||||||
goto abort;
|
goto abort;
|
||||||
|
}
|
||||||
mac_addr_n2a(mac_addr, nla_data(tb[NL80211_ATTR_MAC]));
|
mac_addr_n2a(mac_addr, nla_data(tb[NL80211_ATTR_MAC]));
|
||||||
|
|
||||||
int rem;
|
int rem;
|
||||||
|
@ -75,8 +76,10 @@ bool get_neighbours(struct json_object *result, int ifx) {
|
||||||
neighbours = json_object_new_object();
|
neighbours = json_object_new_object();
|
||||||
if (!neighbours)
|
if (!neighbours)
|
||||||
return false;
|
return false;
|
||||||
if(!nl_send_dump(station_neighbours_handler, neighbours, NL80211_CMD_GET_STATION, ifx))
|
if(!nl_send_dump(station_neighbours_handler, neighbours, NL80211_CMD_GET_STATION, ifx)) {
|
||||||
|
json_object_put(neighbours);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
json_object_object_add(result, "neighbours", neighbours);
|
json_object_object_add(result, "neighbours", neighbours);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,14 @@ static struct json_object *respondd_provider_statistics(void) {
|
||||||
|
|
||||||
wireless = json_object_new_array();
|
wireless = json_object_new_array();
|
||||||
if (!wireless) {
|
if (!wireless) {
|
||||||
//TODO why needed? : json_object_put(result);
|
json_object_put(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
clients = json_object_new_object();
|
clients = json_object_new_object();
|
||||||
if (!clients) {
|
if (!clients) {
|
||||||
|
json_object_put(wireless);
|
||||||
|
json_object_put(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +85,7 @@ static struct json_object *respondd_provider_neighbours(void) {
|
||||||
|
|
||||||
wireless = json_object_new_object();
|
wireless = json_object_new_object();
|
||||||
if (!wireless) {
|
if (!wireless) {
|
||||||
//TODO why needed? : json_object_put(result);
|
json_object_put(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +100,10 @@ static struct json_object *respondd_provider_neighbours(void) {
|
||||||
if (!station)
|
if (!station)
|
||||||
goto next_neighbours;
|
goto next_neighbours;
|
||||||
|
|
||||||
if (!get_neighbours(station, ifaces->ifx))
|
if (!get_neighbours(station, ifaces->ifx)) {
|
||||||
|
json_object_put(station);
|
||||||
goto next_neighbours;
|
goto next_neighbours;
|
||||||
|
}
|
||||||
|
|
||||||
if (ifaces->frequency)
|
if (ifaces->frequency)
|
||||||
json_object_object_add(station, "frequency", json_object_new_int(ifaces->frequency));
|
json_object_object_add(station, "frequency", json_object_new_int(ifaces->frequency));
|
||||||
|
|
Loading…
Reference in New Issue