respondd-module-wifi: free json_object by json_object_put

This commit is contained in:
Martin/Geno 2018-09-25 21:48:19 +02:00
parent 8247f333e4
commit 0376376945
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
2 changed files with 15 additions and 8 deletions

View File

@ -13,10 +13,8 @@ static int station_neighbours_handler(struct nl_msg *msg, void *arg) {
struct json_object *neighbour, *json = (struct json_object *) arg;
neighbour = json_object_new_object();
if (!neighbour) {
//TODO why needed? : json_object_put(result);
if (!neighbour)
goto abort;
}
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) {
fputs("respondd-module-wifi: station data missing in netlink message\n", stderr);
json_object_put(neighbour);
goto abort;
}
char mac_addr[20];
if (!tb[NL80211_ATTR_MAC])
if (!tb[NL80211_ATTR_MAC]) {
json_object_put(neighbour);
goto abort;
}
mac_addr_n2a(mac_addr, nla_data(tb[NL80211_ATTR_MAC]));
int rem;
@ -75,8 +76,10 @@ bool get_neighbours(struct json_object *result, int ifx) {
neighbours = json_object_new_object();
if (!neighbours)
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;
}
json_object_object_add(result, "neighbours", neighbours);
return true;

View File

@ -21,12 +21,14 @@ static struct json_object *respondd_provider_statistics(void) {
wireless = json_object_new_array();
if (!wireless) {
//TODO why needed? : json_object_put(result);
json_object_put(result);
return NULL;
}
clients = json_object_new_object();
if (!clients) {
json_object_put(wireless);
json_object_put(result);
return NULL;
}
@ -83,7 +85,7 @@ static struct json_object *respondd_provider_neighbours(void) {
wireless = json_object_new_object();
if (!wireless) {
//TODO why needed? : json_object_put(result);
json_object_put(result);
return NULL;
}
@ -98,8 +100,10 @@ static struct json_object *respondd_provider_neighbours(void) {
if (!station)
goto next_neighbours;
if (!get_neighbours(station, ifaces->ifx))
if (!get_neighbours(station, ifaces->ifx)) {
json_object_put(station);
goto next_neighbours;
}
if (ifaces->frequency)
json_object_object_add(station, "frequency", json_object_new_int(ifaces->frequency));