ike-cfg: Fix memory leak when matching against ranges
authorTobias Brunner <tobias@strongswan.org>
Mon, 29 May 2017 08:49:57 +0000 (10:49 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 29 May 2017 08:50:58 +0000 (10:50 +0200)
traffic_selector_t::to_subnet() always sets the net/host (unless the
address family was invalid).

Fixes: 3070697f9f7c ("ike: support multiple addresses, ranges and subnets in IKE address config")

src/libcharon/config/ike_cfg.c

index 480dd37..9330078 100644 (file)
@@ -224,12 +224,12 @@ static u_int match(linked_list_t *hosts, linked_list_t *ranges, host_t *cand)
                        if (ts->to_subnet(ts, &host, &mask))
                        {
                                quality = max(quality, mask + 1);
-                               host->destroy(host);
                        }
                        else
                        {
                                quality = max(quality, 1);
                        }
+                       host->destroy(host);
                }
        }
        enumerator->destroy(enumerator);