respondd-module-airtime: fix null pointer deref
In case a radio exists, but is disabled, the survey request will return successfully, but without data. The code could not handle this case, as the newest_element_index would be negative in this case, leading to json_object_array_get_idx returning a null-pointer. Check for a null pointer prior adding the PHY index, avoiding a null-pointer dereference. Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
parent
b644a2a8d8
commit
825aa0c093
|
@ -26,9 +26,10 @@ static struct json_object *respondd_provider_statistics(void) {
|
|||
while (ifaces != NULL) {
|
||||
ok = get_airtime(wireless, ifaces->ifx);
|
||||
if (ok) {
|
||||
newest_element_index = json_object_array_length(wireless)-1;
|
||||
newest_element_index = json_object_array_length(wireless) - 1;
|
||||
last = json_object_array_get_idx(wireless, newest_element_index);
|
||||
json_object_object_add(last, "phy", json_object_new_int(ifaces->wiphy));
|
||||
if (last)
|
||||
json_object_object_add(last, "phy", json_object_new_int(ifaces->wiphy));
|
||||
}
|
||||
void *freeptr = ifaces;
|
||||
ifaces = ifaces->next;
|
||||
|
|
Loading…
Reference in New Issue