OLSR / olsrd

OLSR.org main repository - olsrd v1 - maintained by Freifunk Berlin
Other
84 stars 65 forks source link

olsrd_gyn_gw: possible memory leak in finish function #85

Closed PolynomialDivision closed 4 years ago

PolynomialDivision commented 4 years ago

hna_groups is a list. Actually the finish function should iterate over the list and free ping_hosts and hna_list for every hna_group entry.

(not tested or compiled)

void olsrd_plugin_fini(void) {
  while(hna_groups) {
    while (hna_groups->ping_hosts) {
      struct ping_list* next = hna_groups->ping_hosts->next;
      free(hna_groups->ping_hosts->ping_address);
      free(hna_groups->ping_hosts);
      hna_groups->ping_hosts = next;
    }

    while (hna_groups->hna_list) {
      struct hna_list * next = hna_groups->hna_list->next;
      free(hna_groups->hna_list);
      hna_groups->hna_list = next;
    }
  struct hna_group* next = hna_groups->next;
  free(hna_groups);
  hna_groups = next;
  }
}

https://github.com/OLSR/olsrd/blob/master/lib/dyn_gw/src/olsrd_dyn_gw.c#L313